jquery each div problem

each, html, jquery

Solution

You can only use a specific id for one element in a page. Use a class instead:

<div class="historial">some html code</div>
<div class="historial">some html code</div>
<div class="historial">some html code</div>
<div class="historial">some html code</div>

$(".historial").each(function(e) {
  alert("one div");
});

Problem

I need to obtain all the divs with a given id but the jquery each function only obtain the first one. Example: ``` <div id="#historial">some html code</div> <div id="#historial">some html code</div> <div id="#historial">some html code</div> <div id="#historial">some html code</div> ``` script: ``` $("#historial").each(function() { alert("one div"); }); ``` if I pass a anchor o a id + anchor ej $("#lala a") it's works ok. What's wrong? BR

Original source