Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<div id="div1"></div>
<div id="div2">bla</div>
<div id="div3">  </div>
<div id="div4"><span></span></div>
 
var divs = document.querySelectorAll('div');
[].forEach.call(divs, function(el) {
  hasContent(el);
});
function hasContent(el) {
    if (el.innerHTML.trim() !== '') {
        // It has at least one
        console.log(el.id + ' has content!')
    }
    else(console.log(el.id + ' has no content!'))
}
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers