【发布时间】:2017-01-02 08:39:37
【问题描述】:
我使用了多个 EventListener,但这个特定的在 IE 中不起作用:
document.querySelector('#assets').addEventListener('loaded', function () {
document.getElementById('startbutton').style.display = "inline";
});
document.querySelector('#assets').addEventListener('loaded', function () {
document.getElementById('loadingbutton').style.display = "none";
});
我想在加载资产时显示一个按钮,然后在加载资产后立即删除不显示的按钮。问题是加载按钮没有被删除,因此没有应用样式。这只发生在 Internet Explorer 中。我如何使用 attachEvent 编写它以便它工作?
按钮 html:
<button id="startbutton" class="my_popup_close button" onclick="playSound();setTimeout(showDiv, 2000);" name="answer" value="Show Div" style="display: none;">Ready</button>
<button class="buttonloading loader" id="loadingbutton">Loading<span class="loader__dot">.</span><span class="loader__dot">.</span><span class="loader__dot">.</span></button>
【问题讨论】:
-
监听的两个事件是一样的,结合回调命令,自己省几个字节。
-
你有工作代码示例吗?
标签: javascript html button event-handling