我有JavaScript代碼,必須上移和下移div。當我點擊它時,我希望它上升,然後當我點擊第二次時,我希望它下降。我的代碼是這樣的:JavaScript不會觸發不,如果沒有其他
function why()
{
if (document.getElementById("newton").style.bottom == 23) {
alert("I entered the IF");
document.getElementById("newton").style.bottom = 0;
}
else {
alert("I entered the ELSE");
document.getElementById("newton").style.bottom = 23;
}
}
奇怪的是,我第一次點擊的div它上升,並告訴我被處決一部分人,但在此之後,點擊它不會產生任何效果,不會回落。爲什麼是這樣?