xxxxxxxxxx
//You can check if a div element's content is empty by checking the textContent property
//or the innerHTML property of the element.
let div = document.getElementById("example");
if (!div.textContent.trim()) {
console.log("The div is empty");
}
//The textContent property returns the text content of an element and its
//descendants, including any text that is hidden by CSS styles.
//You can use the trim() method to remove any leading or trailing whitespace
//from the textContent property. This way you can check if the div is empty
//even if it has only whitespaces.
//You can also check if the content of a div element is empty by using the innerHTML property:
let div = document.getElementById("example");
if (!div.innerHTML) {
console.log("The div is empty");
}
//The innerHTML property returns the HTML content of an element.
//It returns an empty string if the element has no children.