Sjmon
Sjmon

Reputation: 553

jquery focus problem

Hello all im trying to add a class when i focus on a small image but it dont add the class, what im doing wrong?

http://jsfiddle.net/6rnU4/

Upvotes: 0

Views: 214

Answers (2)

Liam Bailey
Liam Bailey

Reputation: 5905

Firstly in the latest jquery you need $(document).ready().

Secondly you were overcoding the hide all but first.

And you had missed out the img from your identifier on the add class block, see:

Addition:: Brad Christie is right, if you just want to add a border you should use :hover in your css, if this is just for testing then http://jsfiddle.net/6rnU4/10/ this now works.

further to the changes above, In your css the .hover was being overridden by #small-image img because it has greater specificity.

Upvotes: 0

Brad Christie
Brad Christie

Reputation: 101604

What's wrong with the :hover pseudo-class?

#small-image img:hover {
  border: 5px solid #333;
}

Or

#small-image:hover {
    border: 5px solid #333;
}

(depending your intent)

Also, #hover implies this is a page element with the ID "hover", not an element with the class hover applied. I think you're looking for .hover

Upvotes: 3

Related Questions