I have a simple nested list.
<ol id="draggable" class="nested-sort">
<li data-id="1">Lion</li>
<li data-id="2">Snake</li>
<li data-id="3">Butterfly
<ol data-id="3">
<li data-id="31">Fish</li>
<li data-id="32">Cat</li>
<li data-id="33">Monkey</li>
</ol>
</li>
<li data-id="4">Parrot</li>
</ol>
I want to get all IDs of the <li> as a multidimensional array. Therefore I tried to used jQuery's .each(), but that returns only one iteration.
$( "#draggable li" ).each(function( index ) {
console.log( index + ": " + $( this ).text() );
});
That results in the following output:
0: Lion
1: Snake
2: Butterfly
Fish
Cat
Monkey
3: Fish
4: Cat
5: Monkey
6: Parrot
$(this).data('id')instead?