Home > Web Front-end > JS Tutorial > 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?

黄舟
Release: 2017-06-28 13:42:21
Original
1721 people have browsed it

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){。。。。。。};
Copy after login

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());
}
Copy after login
$("#div_menu_1_con a").mouseover(function () {
var activeElement=this;
handle = setTimeout(function(){
changethis(activeElement);
}, 3000);
}).mouseout(function () {
clearTimeout(handle);
});
function changethis(selector){。。。。。。};
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template