title: How to get a list of values with jquery each function
body: <p>I'm trying to get data value from an <code>&lt;li data-nid="1"&gt;</code> tag. The <code>&lt;li&gt;</code> list is generated from an <code>Ajax</code> query response.</p>
  
  <pre><code>$.each(data.notifications.detail,function(index, element){
  $('#notifications_list').append('&lt;li id="element" data-nid ='+element.id+'&gt;&lt;a&gt;'+element.texte+'&lt;/a&gt;&lt;/li&gt;');
  });
  </code></pre>
  
  <p>to recover value, I tried the following method :</p>
  
  <pre><code>var array = new Array();
    $( "#element").each(function() {
          var id = $( this ).data( "nid" );
          array.push(id);
     });
  </code></pre>
  
  <p>But i'm always getting just one element, and its always the first one. So maybe someone clarify me the situation.</p>