所以,我将这个 opDiv1
设置为 onMouseOver="mhover(opDiv1)"
但我想更改函数 onMouseOver
如果浏览器是IE。
我正在使用这个:
if (ie!=undefined) { //If IE detected
$('#opDiv1').attr("onMouseOver","mhover_ie('opDiv1')")
}
但是,如果我使用 IE(任何版本),它不会改变 onMouseOver
的功能
最佳答案
你可以这样改变 IE 的 onMouseOver-event
if (ie != undefined) {
document.getElementById('opDiv1').onmouseover = function () { mhover_ie('opDiv1'); };
};
信息: 将函数分配给 onclick 属性不会向 DOM 节点添加属性。
关于javascript - 使用 .attr 更改 onMouseOver,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18230225/