欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  web前端

jquery如何将当前mouseover所在元素传递赋值给其内部函数?

程序员文章站 2022-05-03 15:01:52
...
我的代码截取如下:
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所在元素传递赋值给其内部函数?的详细内容,更多请关注其它相关文章!