Delete or remove an element in jQuery

To delete an element from dom, you need to choose any one of following whichever suites your purpose better:

// remove all children
$(“#mainContent”).empty();


// remove selection
$(“span.names”).remove();


// change position
$(“p”).remove(“:not(.red)”)
		.appendTo(“#main”);



?’s, let me know.


Anoop Kumar Sharma

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>