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...
Just wrap all those elements in a div and remove them
$('#select-wrapper').remove();
or do it a little more friendlier
$('#select-wrapper').fadeOut(500, function() { $(this).remove(); });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With