我有以下问题: 我有一个图像。当用户单击它时,它会显示一个警报框,但如果用户双击它,我也想将其删除。我有以下标记,但它不起作用。
<h1>hello </h1>
<img src="smile.png" class=" center-block" onclick="alert('Hello')" ondblclick="$('img').remove();">
唯一有效的部分是警报按钮
注意:jquery已加载
最佳答案
来自MDN :
Dialog boxes are modal windows - they prevent the user from accessing the rest of the program's interface until the dialog box is closed. For this reason, you should not overuse any function that creates a dialog box (or modal window).
如果您在点击时触发 alert()
,UI 将被禁用,并且在不关闭 alert()
的情况下您无法立即执行后续点击。 (您应该听到警告声)
关于javascript - ondblclick 不适用于带有 onclick javascript 的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27206488/