我'm using the datatables plugin to display a table. In the configuration parameters I'已设置 bJQueryUI : true
所以该表应用了当前jQuery UI样式的样式,我添加了一些图标来对该行执行操作 . 问题是,数据表的图标和 Headers 上的悬停事件仅适用于Firefox,Chrome或IE中的事件未触发 .
我正在使用的代码是这样的:
$('.ui-state-default').live({
mouseenter:
function(){ $(this).addClass('ui-state-hover'); },
mouseleave:
function(){ $(this).removeClass('ui-state-hover'); }
});
1 回答
您是否在开发人员工具中检查了要悬停的区域中元素的分层?您应该检查项目的z-index以确保
.ui-state-default
元素位于顶部 .你也应该为
.delegate()
更改.live()
. 它们类似,但您可以使用.delegate()
设置根元素,并使用.live()
根元素始终是document
元素:自jQuery 1.7起
.live()
已被折旧 . jQuery 1.7中有一个名为.on()
的新函数,它与.bind()
和.delegate()
的作用相同,具体取决于使用的语法:http://api.jquery.com/on