David Bradshaw
David Bradshaw

Reputation: 13077

Is there a way to get all elements with a :hover class in jQuery?

I have a problem that needs me to find all elements with a :hover class. Is there a way to do this. I was expecting to be able to do `$(':hover'), but strangely that doesn't seem to work.

What I wanted to be able to do was.

$('*:hover').mouseover(myFunction).mouseout(myFunction);

Upvotes: 1

Views: 279

Answers (1)

P̲̳x͓L̳
P̲̳x͓L̳

Reputation: 3653

This will grep by class name :hover

$.grep($('*'), function(fn) { return $(fn).hasClass(':hover') })

Upvotes: 1

Related Questions