JavaScript
Article

jQuery Clear Div Contents

By Sam Deering

Simple jQuery code snippet to clear the contents of a div. Nothing special, this function shows just how easy it is to remove stuff from the DOM using jQuery.

$('#div').empty();

Read more: http://api.jquery.com/empty/

$('#div').remove();

Read more: http://api.jquery.com/remove/

  • http://www.jampersonals.com Jamaica Dating

    Thank you for this post, was looking for a quick reference and came across your post.

  • charan

    Thank you for the solution.

  • abhishek

    How can i remove a div from view source.

Recommended
Sponsors
Because We Like You
Free Ebooks!

Grab SitePoint's top 10 web dev and design ebooks, completely free!

Get the latest in JavaScript, once a week, for free.