Remove the elements and contents before an element

Posted by Jerry on Stack Overflow See other posts from Stack Overflow or by Jerry
Published on 2010-06-01T00:16:31Z Indexed on 2010/06/01 0:23 UTC
Read the original article Hit count: 516

Filed under:
|
|

Hello guys I am trying to remove the elements and contents before a link inside a div when a user clicks a button. What is the best way to do it??

<div id="dialog" class="window">  

         //will be inserted a <select> element and few text here 
         //but I want to clear them after the user click a button

    <a href="#" class="close">Close it</a>  // I want to keep this <a> link.    

    </div>  

My Jquery

$('.model').click(function(e) {  

   $("#dialog").empty();  //I can't use this because <a> will be deleted. Any better ideas?         

});

Thanks for the reply...

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about form