jQuery remove but not container DIV -


i have function:

$('#addnote').click(function() {     var html =             '<div class="row-fluid" id="notenote"><div class="span9">' +             $('#notecontent').val() +             '<input type="hidden" value="' + $('#notecontent').val() + '" name=notes[]>' +             '</div>' +             '<div class="span3 ">' +             '<img width="68" height="60" src="getimage.php?image=current_admin">' +             '<div class="pull-right">' +             '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' +             '<a href="javascript:void(0)" class="removenote"><i class="icon-remove"></i></a>' +             '&nbsp;&nbsp;' +             '</div>' +             '</div>' +             '</div>';      if ($('#notecontent').val() !== '') {         $('#notecontent').val('');         var newnote = $("#notecontainer").append(html);          newnote.find('.removenote').on("click", function(event) {             event.preventdefault();             newnote.remove();           });     } }); 

the problem when newnote.remove() fired, deletes main container div #notecontainerwhile should remove itself, div #notenote , nothing else. how can fix code?

thanks

replace code:

newnote.remove();   

with this:

$(this).closest('#notenote').remove();   

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -