こんにちは、これは私のjavascriptコードです:
window.onload = function () {
function hideAds() {
setTimeout(hide, 2000);
}
function hide() {
var ads = document.querySelector(".ads");
ads.style.marginTop = (-ads.offsetHeight) + "px";
}
function reveal() {
ads.style.marginTop = "";
hideAds();
}
var ads = document.querySelector(".ads");
ads.addEventListener("click", reveal, true);
hideAds();
}
このコードから、最後から2行目の「ads.addEventListener」以外はすべて正常に動作します。理由は何ですか?私はここで何か間違っていますか..?
広告クラスに追加された div をクリックして、公開機能を呼び出す必要があります。
誰も私を助けますか?