javascript - select specific element using jQuery attr() Method -


If I have 5 images on a page, then all of them are exactly the same image as seen below

  & lt; Body & gt; & Lt; Img src = "http://httpJunkie.com/1st/jQ02/orangeCat.jpg" & gt; & Lt; Img src = "http://httpJunkie.com/1st/jQ02/orangeCat.jpg" & gt; & Lt; Img src = "http://httpJunkie.com/1st/jQ02/orangeCat.jpg" & gt; & Lt; Img src = "http://httpJunkie.com/1st/jQ02/orangeCat.jpg" & gt; & Lt; Img src = "http://httpJunkie.com/1st/jQ02/orangeCat.jpg" & gt; & Lt; / Body & gt;   

I just have to use javascript and I must use jQuery to modify height of each one, assuming that the first 10px x 10px and each continuous image should be increased from 10px I know that I can select one by using the first one:

 < Code> $ ("body img: first"). Attr ({width: 10, height: 10,}); The last one using   

and

  $ ("body img: last") Attr ({width: 60, height: 60,});   

My primary question is how can I select image number 3 by using the .attr () method similar to the code above

I did nth -child and it is not working.

PS: I know that I can use a loop to change them at once?

You can select : eq selector, or eq () method:

  $ ("body img: eq (3)"). Attr ({width: 10, height: 10,}); $ ("Body image"). Eq (3) .attr ({width: 10, height: 10,});   

The above two have only one result.

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -