JavaScript - hasChildNodes
JavaScript - hasChildNodes
by Nirvanachain
HTML
<div id="mainDiv">
</div>
JavaScript
var main = document.getElementById('mainDiv');
/** hasChildNodes() will return 'true' if white-space is present between the opening and closing part of the element. No white-space should be present between the elements opening and closing tags if you want hasChildNodes() to return 'false' in firefox. **/
main.replace(/^(\s*)|(\s*)$/g, '').replace(/\s+/g, ' ');
alert( main.hasChildNodes() );
alert( main.children.length );
alert( main.firstChild.nodeName );