- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
以下javascript成功触发alert
在 <button>
适用于 Chrome 但不适用于 Firefox 的元素;使用 Firefox,alert
未触发:
element.addEventListener('mouseover', function(){ alert('mouseover') }, false);
当我替换 element
时html 到 <span>
, 事件触发了预期的 alert
在 Firefox 中,正如预期的那样。
违规的 html:
不工作 html
<button id="button-upload"><span>upload</span></button>
工作 html
<span id="button-upload"><span>upload</span></span>
在 firefox 中,事件不会冒泡到 child 的按钮吗?
如果是这样,是否有解决方法 - 除了替换 button
与 span
由于 CSS。
最佳答案
你可以这样做吗?
html:
<div><button id="button-upload"><span>upload</span></button></div>
JavaScript:
document.getElementById('button-upload').parentNode.addEventListener('mouseover', function(){ alert('mouseover') }, false);
关于javascript - Firefox addeventlistener ('mouseover' ,...) 在 <button> 上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18645598/
我遇到过这个 html: 上面的html和这个有什么区别: 最佳答案 来自MDN page on the tag : 对于 type 的属性标签,可能的值是: 提交:按钮将表单数据提交给服务器
Button button= (Button) findViewbyID(R.id.button); 和 Button button = new Button(this); 有什么区别? 最佳答案 有
我是一名优秀的程序员,十分优秀!