我通过将SVG路径元素作为其父级的最后一个子元素响应mouseenter事件,使该路径出现在其他元素的上方(SVG上不支持z-index)。但问题是,在Firefox上这会导致mouseleave事件触发。在Chrome上这个方法很好用。
// on mousenter
node.parentNode.appendChild(node)
// this triggers a mouseleave .. if i don't move the node it works
有没有人知道解决方法或其他方法?
(这段文字是关于IT技术的问题)
ignore = true; ...append(...); setTimeout(function() { ignore = false; }, 0);
请注意,setTimeout
在可能已将调用排队到事件处理程序的DOM操作之后(因此您的处理程序在setTimeout
回调之前), - T.J. CrowderappendChild
同步(它很可能是),还是在渲染期间稍后进行。 - T.J. Crowder