javascript day5
6392 ワード
今回は、画面の下部にある今日の名言がどのように発表されているのかを見てみましょう.
今回の仕事で重要なのは、ランダムに名言を言うことです.
<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);
Reference
この問題について(javascript day5), 我々は、より多くの情報をここで見つけました https://velog.io/@ralo-gimhae/javascript-day5テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol