empty div jquery
snippet in javascript

empty div jquery

user2644


  
    $("button").click(function(){

   $("div").empty();

 });
  
 

jquery if div is empty

user5088

  function isEmpty( el ){
      return !$.trim(el.html())
  }
  if (isEmpty($('#element'))) {
      // do something
  }

jquery clear text in div

user5027

// removes only text, no changes to children
$('#YourDivId').contents().filter((_, el) => el.nodeType === 3).remove();

.empty() in jquery

user6024

// Remove all child nodes of the set of matched elements from the DOM
// This method does not accept any arguments.
$("div.parent").empty();

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