我想在點擊按鈕後隱藏div,這應該是一件非常簡單的事情,但我得到一個錯誤。我有以下代碼:當試圖隱藏div時出錯
<div id="clearSale" onclick=playSound("sounds/Register.mp3") class="botonCLS">
<button id="clearSaleBtn" type="button" style="position:relative; z-index:0; width: 90px; height: 32px; left: -6px; top: 0px;">Clear Sales</button>
<div id="check" style="display: none">
<button id="confirm" style="margin-left: 5px">Send confirmation</button>
</div>
所以我想要做的就是更換的第一個與第二個當按鈕clicked..So通常就夠了,我說這條線在我的JS函數,當我收到一個推送通知(工作),它被稱爲:
document.getElementByID("clearSaleBtn").style.display = "";
但我得到一個錯誤的對象不支持getelementbyid方法。我猜這可能與div是一個類的事實有關?有沒有辦法解決?或者有沒有辦法可以更改清除銷售按鈕中的文本發送確認或類似的東西
@ Kevin Bowersox謝謝!不知道我是怎麼錯過的!我現在沒有收到錯誤信息,但由於某種原因,按鈕不會消失。任何想法爲什麼? – user2363025
@ user2363025查看更新 –