user730569
user730569

Reputation: 4004

Is it possible to bind a jquery call to two CSS selectors?

I want to bind a mouseout call to two CSS selectors so that if I've moved my mouse from one AND the other element, then I call something else. Is this even possible?

Upvotes: 3

Views: 119

Answers (2)

JohnP
JohnP

Reputation: 50019

$('.class1, .class2').mousemove(callbackFunction);

jQuery selectors work just like CSS. Just use a comma to separate the classes.

Upvotes: 0

rahul
rahul

Reputation: 187050

You can use something like

$("#selector1, #selector2").bind("mouseout", function(){
    // code goes here
});

Read Multiple Selector (“selector1, selector2, selectorN”)

Upvotes: 5

Related Questions