I am trying to do a loop to check all the elements with a class selector.
I have
html
<div class='label'>aaaa</div>
<div class='label'>bbbb</div>
<div class='label'>cccc</div>
<div class='label'>dddd</div>
var pre=$('.label')
pre.each(function(e){
console.log(e);
})
but it doens’t show the element (aaaa,bbbb..etc).
How do I do this? Thanks a lot
DEMO
First argument of
.each()isindexand second argument isvalue(here your target element).Read more about
.each().