how to delete element created with jquery ?!

Posted by mehdi on Stack Overflow See other posts from Stack Overflow or by mehdi
Published on 2010-06-11T12:58:00Z Indexed on 2010/06/11 13:02 UTC
Read the original article Hit count: 159

Filed under:

hi , i have write this block of code in jquery to create three element after some events

$('body').append(
tmp= $('<div id="tmp"></div>')
);

$('<div id="close" />').appendTo("#tmp");   
$('<div id="box-results" />').appendTo('#tmp');

this three elements are created normally and added to my DOM but i want to remove them with some function like this :

$("#close").click(function(e){

e.preventDefault();
$("#tmp").remove(); 
//$("#overlay").remove(); 
});

and after i click close div noting happen ! what's wrong with my code ?

© Stack Overflow or respective owner

Related posts about jQuery