0

How can i get the $(this) in the setTimeout to get the hover function's selector in the case below img.

$("img").hover(function(){
window.setTimeout(function() {  
    $(this).addClass("hovering"); // add class .hovering to the exact img being hovered
}, 500);  
});

1 Answer 1

1

Put this in some other variable.

$("img").hover(function() {
    var $this = $(this);

    window.setTimeout(function() {  
        $this.addClass("hovering"); // add class .hovering to the exact img being hovered
    }, 500);  
});
Sign up to request clarification or add additional context in comments.

1 Comment

@RepWhoringPeeHaa: Stop bashing my improper terminology with rhetorical questions! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.