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 출력
'IT > JavaScript' 카테고리의 다른 글
현재 위치를 알아내는 방법 (0) | 2022.12.16 |
---|---|
백그라운드 이미지 랜덤하게 지정하기. (0) | 2022.11.17 |
간단한 시계 만들기 (0) | 2022.11.16 |
Explorer fetch 지원 안되는 이슈 처리 방법 (0) | 2021.09.07 |
Explorer 지원 안되는 자바스크립트 function 대체 방법 (2가지) (0) | 2021.09.07 |