I wanted to know how I can check if a div is empty by javascript without using jquery only with pure javascript.
Because I have searched and only with jquery I can find it and I need it only with pure javascript.
I wanted to know how I can check if a div is empty by javascript without using jquery only with pure javascript.
Because I have searched and only with jquery I can find it and I need it only with pure javascript.
You can do something like this:
var divs = document.getElementsByTagName('div');
for (var i = 0; i < divs.length; i++) {
if(divs[i].innerHTML == "") {
console.log(divs[i].id);
}
}
<div id="div1">
<label>Hello</label>
</div>
<div id="div2"></div>