IT/JavaScript
명언 랜덤하게 출력하기!
Tommy
2022. 11. 17. 08:10
728x90
* Index.html
1. index.html 에 "js/quotes.js" import
2. <div id="quote"></div> 추가 -> 안에 <span> 태그 2개 추가
* quotes.js
1. const quote[] 명언 배열로 저장
2. const const / author --> index.html의 요소 중 id 가 'quote' 인 부분을 가져오기
( span:first-child span:last-child ) --> span 태그 중 첫번째 요소 / 마지막 요소
3. const todayQuote --> 배열 길이만큼 랜덤하게 data 추출
4. quote / author.innerText -> span 태그내에 랜덤하게 추출한 명언 Data 출력