jak sprawdzić, czy div ma identyfikator czy nie?
<div id="cardSlots">
<div class="ui-droppable" tabindex="-1" id="card1">one</div>
<div class="ui-droppable" tabindex="-1" id="card2">two</div>
<div class="ui-droppable" tabindex="-1">three</div>
<div class="ui-droppable" tabindex="-1">four</div>
</div>
<script>
$(".ui-droppable").each(function () {
if($(this).attr("id").length>0)
{
alert('here');
}
});
</script>
Próbuję przechodzić przez klasę, ale problem polega na tym, że mam duplikaty identyfikatorów card1 i card2 na tej stronie. ale powyższy kod wydaje się działać, ale pokazuje błąd poniżej.
Uncaught Type Error: Cannot read property 'length' of undefined
Próbuję uzyskać identyfikatory z istniejącej pętli.