我有HTML代碼是這樣的:如何在另一個功能後彈出警報?
<button id="hide" onclick="hide()">Hide</button>
<p id="pb">This is a paragraph with little content.</p>
使命是,當我按一下按鈕,該段將在後面躲,然後再警報()彈出。我嘗試了很多方法並繼續使用Google,但是我沒有任何改進。這是我最初的CS和JS代碼:
CSS:
.hide {
display: none;
}
JS
var button = document.getElementById("hide");
var p = document.getElementById("pb");
function hide(){
p.classList.add("hide");
alert("The paragraph gone!");
}
隱藏() - >警報彈出先款隱藏。這不是我想要的。 謝謝!
爲什麼你想這樣做? –
附加要求是我不允許使用setTimeOut函數。 –
@KhanhNguyen - 爲什麼不呢? – Quentin