If there is someone like me who doesn't want to use jQuery, here is an example in javascript (only) ...
Files
Html file ...
<body> <section id="bar"></section> </body>
Javascript file ...
foo = document.getElementById('bar'); function isEmpty(){ if (foo.innerHTML.length === 0) { } }
What I've done
In HTML
Pretty simple, I just created a section and assigned it an ID. This identifier will be used to call it in our javascript.
In javascript
In var fooI, I called the section for which I gave an identifier. After that, I created a function that “does something” if the length of the element is zero.
Questions
This works, but if you have a space or line break, the code will not consider it "empty" ...
source share