this prob quite weird or simple error. it's doing head in lol. code below click event handler aimed @ 2 <img> elements. click on 1 <img> element classed "undo" - should remove <img> being clicked , element classed "bin" directly next @ same time. manage either 1 or other removed not both. can please? thank walter
js:
$('ul').on('click','.undo',function(e) { $(this).remove(); $(this).prev().remove(); html:
<img src="images/bin.png" align="right" class="bin"> <img src="images/undo.png" align="right" class="undo">
once call $(this).remove();, element removed dom, thereafter $(this).prev() not find element there won't previous sibling detached element
$('ul').on('click', '.undo', function (e) { $(this).prev().addback().remove(); or
$('ul').on('click', '.undo', function (e) { $(this).prev().remove(); $(this).remove();
Comments
Post a Comment