1

我有一个侧面有一个小按钮的表格,它会自动移动到用户鼠标所在的任何行。当鼠标移动时,按钮的包含范围(以及其中的所有元素)使用 insertBefore() 函数移动。然而,按钮有一个注册的 onclick 事件处理程序(使用 attachEvent()),一旦按钮被移动,onclick 事件将不再触发。

这是一个已知的问题?

4

1 回答 1

1

Using insertBefore, appendChild and other DOM manipulation methods keeps event handlers in all browsers, so that's not your problem.

I've tried to reproduce described problem and I see the bug with the click in IE8. The button simply sticks in pressed state and click handler doesn't fire. Never seen such bug before.

To fix this issue you can use mouseenter event instead of mouseover. (This event is built in in IE, but not in all modern browsers. To make this crossbrowser you can use jQuery mouseenter).

JSFiddle links (look in IE8): with bug and fixed version

于 2012-11-18T18:15:59.197 回答