jquery iterate ul within li -
i'm using following code iterate html element given below
<ul id="sortable"> <li> <p> item 1</p> <ul id="nested-sortable"> <li> sub item 1 </li> <li> sub item 2 </li> <li> sub item 3 </li> </ul> </li> <li> <p> item 2</p> </li> </ul>
javascript
var jsonseqobj = {}; alert('hi'); $('ul#sortable li').each(function(index,pele) { alert($(pele).attr('id')); $(pele).children('ul#nested-sortable li').each(function(idx, chele) { alert(chele.attr('id')); jsonseqobj.push({ref_id:$(chele).attr('id') , new_seq_no:idx }); }); jsonseqobj.push({ref_id:$(pele).attr('id') , new_seq_no:index }); });
li ul li long, line wraps no indention
alert(jsonseqobj); return jsonseqobj;
but children thing not working
error : object doesnt support property.
is markup same in example? or have more 1 nested-sortable ul-s? maybe problem have duplicated ids on page (id should unique).
Comments
Post a Comment