ajax - get id of all child div jquery -
html code
<div class="dd" id="nestable"> <ol class="dd-list"> <li class="dd-item" data-id="1"> <div class="dd-handle" id="1">item 1</div> </li> <li class="dd-item" data-id="11"> <div class="dd-handle" id="11">item 11</div> </li> <li class="dd-item" data-id="12"> <div class="dd-handle" id="12">item 12</div> </li> </ol> </div> i want pass child div ids such 1,11,12 via ajax.
this code.
$('#nestable').nestable({ group: 1 }) .on('change', updateoutput,function(event){ var a=$("#nestable :first-child").attr('id'); $.ajax({ url: 'drag', data: {sorted_list: $(this).text()}, datatype: 'json', }); }); i should pass child div ids(1,11,12) under div(#nestable). how can achieve this?
try this:
$('#nestable').nestable({ group: 1 }) .on('change', updateoutput,function(event){ var childids = $('.dd-list div', this).map(function() { return this.id; }); $.ajax({ url: 'drag', data: { sorted_list: childids }, datatype: 'json' }); });
Comments
Post a Comment