這是我的腳本:的Javascript切換問題
window.onload = function(){
var title = document.getElementsByTagName('h1')[0].id = "heading1";
document.getElementById(title).onclick = function (e){
var para = this.nextSibling.style.display = 'block';
var newVal = (para == "block") ? "none" : "block";
alert(newVal);
}
}
結果我需要的是警戒值切換從塊沒有和背部。但我總是得到「沒有」。我的代碼有什麼問題?
非常感謝。它工作正常。 – 3gwebtrain 2010-11-13 13:20:16
它工作正常。但我現在還有另一個問題。實際上在我的代碼中,我提到nextSibling是段落標記。它應該需要顯示和隱藏。但它不能與Internet Explorer一起工作,因爲它將數字作爲字符來計算空白空間。 – 3gwebtrain 2010-11-13 14:20:11
如何忽略Internet Explorer的空白區域? – 3gwebtrain 2010-11-13 14:20:38