Home  >  Article  >  Web Front-end  >  How does jquery pass and assign the element where the current mouseover is located to its internal function?

How does jquery pass and assign the element where the current mouseover is located to its internal function?

黄舟
黄舟Original
2017-06-28 13:42:211694browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn