一个简单的黑客就是这样说:
var hoverElem = null;
$('*').hover(function() {hoverElem = this});
Run Code Online (Sandbox Code Playgroud)
然后当你需要调用什么函数来获取值时,只需使用hoverElem
编辑:这是一个资源密集度较低的电话:
$('*').live('mouseenter', function() { hoverEleme = this; });
Run Code Online (Sandbox Code Playgroud)
编辑2:由于.live()被弃用,你应该使用.on()
$("*").on("mouseenter", function() { hoverElem = this; });
Run Code Online (Sandbox Code Playgroud)
$('*').on('mouseenter', function() { hoverEleme = this; });
Run Code Online (Sandbox Code Playgroud)
这比将鼠标处理程序附加到每个元素(也在mouseleave上触发)要便宜得多,尤其是你得到的元素越多.
| 归档时间: |
|
| 查看次数: |
14251 次 |
| 最近记录: |