Ads by ProfitSence
Close

Clear all div's contents inside a parent div.

Last Updated on Wednesday 5th Oct 2022

.empty jquery

JQuery's empty() function does just that.

empty div jquery Syntax

			
					$(selector).empty()

			
	

Remove all child nodes of the set of matched elements from the DOM.This method removes not only child elements.

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

			
	

clears the container div.

jQuery clear div contents

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

			
	

clears all the child div

Remove the content of all <div> elements.

			
					$("button").click(function(){
  $("div").empty();
});

			
	

If you were trying to do this using Vanilla JavaScript, you could use the innerHTML property and set it to an empty string.

			
					document.getElementById('container').innerHTML = '';