setTimeout 사용 방법
3889 단어 JavaScript
setTimeout <h3>全ての色が混ざり合うと白くなるものは何か?</h3>
<h4 id="temporaryBox" class="temporaryBox">加法減色
<p><img src="img/rgb.png" alt=""></p></h4>
<p>
<input type="button" value="答えを見る" id="btnShowBox" class="btn" onclick="showBox();">
</p>
let timerId;
// ボックスを表示して、タイマーを開始
function showBox() {
document.getElementById("temporaryBox").style.display = "block"; // ボックスを表示
timerId = setTimeout( closeBox , 5000 ); // タイマーを開始
document.getElementById("btnShowBox").disabled = true; // 表示用ボタンを無効化
}
// ボックスを消して、タイマーを終了
function closeBox() {
document.getElementById("temporaryBox").style.display = "none"; // ボックスを消す
clearTimeout( timerId ); // タイマーを終了
document.getElementById("btnShowBox").disabled = false; // 表示用ボタンを有効化
}
Reference
이 문제에 관하여(setTimeout 사용 방법), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/kyototea/items/539c194c830b8782ceec
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
<h3>全ての色が混ざり合うと白くなるものは何か?</h3>
<h4 id="temporaryBox" class="temporaryBox">加法減色
<p><img src="img/rgb.png" alt=""></p></h4>
<p>
<input type="button" value="答えを見る" id="btnShowBox" class="btn" onclick="showBox();">
</p>
let timerId;
// ボックスを表示して、タイマーを開始
function showBox() {
document.getElementById("temporaryBox").style.display = "block"; // ボックスを表示
timerId = setTimeout( closeBox , 5000 ); // タイマーを開始
document.getElementById("btnShowBox").disabled = true; // 表示用ボタンを無効化
}
// ボックスを消して、タイマーを終了
function closeBox() {
document.getElementById("temporaryBox").style.display = "none"; // ボックスを消す
clearTimeout( timerId ); // タイマーを終了
document.getElementById("btnShowBox").disabled = false; // 表示用ボタンを有効化
}
Reference
이 문제에 관하여(setTimeout 사용 방법), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/kyototea/items/539c194c830b8782ceec텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)