How to get attributes values separately for each container present on the webpage in jquery ?

Posted by Rachel on Stack Overflow See other posts from Stack Overflow or by Rachel
Published on 2010-05-04T21:29:27Z Indexed on 2010/05/04 21:38 UTC
Read the original article Hit count: 185

Filed under:
|

This question is in continuation to How to get attributes of container in jquer, I have different containers on my webpage and all of them have <div id = "some values"> now how can I get attributes values separately for each component ?

Is there any way I can know which attribute id belong to which container div ?

Currently I am using :

var id = $( '.promotion' ).attr( 'id' );

But if I have multiple promotional components on page and all have same div attribute as id than how can I relate that this particular attribute id belonged to this specific container ?

Update: I am having a function which is called for each container present on the page and so if I am using above mentioned code than will it not always return me the first match for id in the div and would never go to other divs and so I will always get same value for id which is for the first container ? If so than what is the work around for this ?

Hope this question is clear.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JavaScript