<html>
<head></head>
<body>
<div class="abcd"></div>
<script>
var y = document.getElementsByClassName('abcd');
var x = document.querySelectorAll("abcd");
alert(y[0].hasChildNodes());
alert(x[0].hasChildNodes());
</script>
</body>
</html>
In above code first alert give false but not in alert two. how do i get same result with document.querySelectorAll ?
basically i want it to work in IE8.
document.querySelectorAll()uses the same selectors as CSS to address elements. So instead of using"abcd"as parameter, you should go for".abcd"(note the added.) there.