k1tkat
k1tkat

Reputation: 67

Get all images with certain class

I'm not sure how to ask this question but here is my explanation:

$(".phone img")

I want something like this. How to set an animation only to the images in phone class. This doesn't work obviously. The animation cover the entire class.

Upvotes: 2

Views: 6315

Answers (2)

jquery404
jquery404

Reputation: 674

You can give a class name or Id to the image tag. Something like this

<div class="phone">
<img class="img_1"/>
</div>

Then you can call it like

$('.phone .img_1').animate();

That should do it.

Upvotes: 0

Roberto Maldonado
Roberto Maldonado

Reputation: 1595

What you do in $(".phone img") is to call all img tags inside any tag that has a phone class. In order to match all images that have phone class, then it should be:

$("img.phone")

Upvotes: 8

Related Questions