I thought I had implemented this .each function correctly, but as my script has become more complicated I’ve noticed some odd results.
My goal is to group pairs of items together and organize them based on their parent class.
Below is a simplified version of what I have
Script:
$(."pair").each(function(){
alert($("div").val());
}
HTML:
<div class ="FirstGroup" id="A">
<div class="paired">Header Text</div>
<div class="paired">Body Text</div>
</div>
<div class ="FirstGroup" id="B">
<div class="paired">Header Text</div>
<div class="paired">Body Text</div>
</div>
<div class ="SecondGroup" id="C">
<div class="paired">Header Text</div>
<div class="paired">Body Text</div>
</div>
<div class ="SecondGroup" id="D">
<div class="paired">Header Text</div>
<div class="paired">Body Text</div>
</div>
5 problems
.outside the quotation markspairelementdivhas novalueproperty)pairednotpairI can’t really tell from your question what you intend with this code, but these are some starting points.
If you wanted to select the parent, then you’d do…