How to get attributes values separately for each container present on the webpage in jquery?
<p>This question is in continuation to <a href="http://stackoverflow.com/questions/2768580/how-to-get-attributes-of-container-in-jquery">How to get attributes of container in jquer</a>, I have different containers on my webpage and all of them have <code>&lt;div id = "some values"&gt;</code> now how can I get attributes values separately for each component ? </p>

<p>Is there any way I can know which attribute id belong to which container div ?</p>

<p>Currently I am using :</p>

<pre><code>var id = $( '.promotion' ).attr( 'id' );
</code></pre>

<p>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 ?</p>

<p><strong>Update</strong>: 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 ?</p>

<pre><code>var id = $( '.promotion' ).this.attr( 'id' );


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

var id = this.$( '.promotion' ).attr( 'id' );
</code></pre>

<p>How would I know if the attribute value is for current container, so how should I use this properly to get this information ?</p>

<p>Hope this question is clear.</p>
