Home > Article > Web Front-end > How does jquery pass and assign the element where the current mouseover is located to its internal function?
My code is intercepted as follows:
var handle = null; $("#div_menu_1_con a").mouseover(function () { handle = setTimeout(changethis(???), 3000); }).mouseout(function () { clearTimeout(handle); }); function changethis(selector){。。。。。。};
Above? ? ? The key is to pass the current mouseover element to changethisfunction and let it handle some things!
jQueryThe binding mouseover method is
$("#元素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. Just this.
The above is the detailed content of How does jquery pass and assign the element where the current mouseover is located to its internal function?. For more information, please follow other related articles on the PHP Chinese website!