javascript day5



今回は、画面の下部にある今日の名言がどのように発表されているのかを見てみましょう.
今回の仕事で重要なのは、ランダムに名言を言うことです.
<div class='quotes'>
  <span></span>
  <span></span>
</div>
위처럼 텅빈 span을 만든다.
const quotes = [~~~~]

const myQuotes = document.querySelector('.quotes');

const mySpan =  document.querySelector('.quotes span:first-child');

const mySpanAnother = document.querySelector('.quotes span:last-child');

const todayQuotes = quotes[Math.floor(Math.random()*quotes.length)];

mySpan.innerText = todayQuotes.quote;
mySpanAnother = todayQuotes.author;
上記のような機能を持ち、一定時間ごとにバックグラウンド変換効果を加える.
const backGround = ['1.jpeg', '2.jpeg', '3.jpeg','4.jpeg'];

const bgImage = document.creageElement('img');

function changeBody() {
	const backImage = backGround[Math.floor(Math.random()*backGround.length];
        bgImage.src = '${backImage}';
        document.appendchild(bgImage);                        
};

setIterval(changeBody, 20000);