I am having trouble understanding why my selector is not working for a foreach loop.
My DOM looks as such:
<div id="page1" class="ui-droppable">
<div class="ui-draggable ui-draggable-handle ui-draggable-dragging signatureInstance selected btn-delete" style="position: absolute; left: 185px; top: 470px;">
<img src="http://example.com/img/field.png">
<span class="glyphicon glyphicon-remove btn-delete"><span></span></span>
</div>
<div class="ui-draggable ui-draggable-handle ui-draggable-dragging signatureInstance selected btn-delete" style="position: absolute; left: 171px; top: 562px;">
<img src="http://example.com/img/field.png">
<span class="glyphicon glyphicon-remove btn-delete"><span></span></span>
</div>
</div>
Would someone kindly explain why the following selector is not valid for a foreach iteration?
$('#page1 .signatureInstance').forEach(function(index) {
console.log($(this));
});
or
$('#page1 .ui-draggable .ui-draggable-handle .ui-draggable-dragging signatureInstance .selected .btn-delete').forEach(function(index) {
console.log($(this));
});
or even:
$('#page1 div').forEach(function(index) {
console.log($(this));
});