我的代码截取如下:
var handle = null; $("#div_menu_1_con a").mouseover(function () { handle = setTimeout(changethis(???), 3000); }).mouseout(function () { clearTimeout(handle); }); function changethis(selector){。。。。。。};
上面???处就是要将当前发生mouseover的元素传给changethis函数,让它去处理一些事情!
jQuery绑定mouseover方法是
$("#元素id").mouseover(function(){ //将mouseover所在元素传递赋值给其所在内部函数,就是将元素本身传递给内部函数 //jQuery中元素绑定函数内$(this)就可以获取到当前元素 //所以,如下调用 show($(this));//$(this)将当前元素当作参数传递过去 }); function show(obj){ alert(obj.text()); }
$("#div_menu_1_con a").mouseover(function () { var activeElement=this; handle = setTimeout(function(){ changethis(activeElement); }, 3000); }).mouseout(function () { clearTimeout(handle); }); function changethis(selector){。。。。。。};
this 呀 直接this就可以了
以上就是jquery如何将当前mouseover所在元素传递赋值给其内部函数?的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号