Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8128383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:51:37+00:00 2026-06-06T07:51:37+00:00

<html> <head></head> <body> <div class=abcd></div> <script> var y = document.getElementsByClassName(‘abcd’); var x = document.querySelectorAll(abcd);

  • 0
<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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T07:51:39+00:00Added an answer on June 6, 2026 at 7:51 am

    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.

    <script>
    var y = document.getElementsByClassName('abcd');
    var x = document.querySelectorAll(".abcd");
    alert(y[0].hasChildNodes());
    alert(x[0].hasChildNodes());
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<html> <head></head> <body> <div class=mtb-desc> some contentsome contentsome contentsome contentsome contentsome contentsome contentsome content.
The code is as below: <html> <head> <title>test</title> </head> <body> <div><span>shanghai</span><span class=margin> </span><span>male</span></div> </body>
<html> <head></head> <body> <div id=ctl00_ContentPlaceHolder1_ctl00_ctl01_Showcase> <div style=width:100%;text-align:center;><img src=http://www.xyz.com/aaa.gif id=ctl00_ContentPlaceHolder1_ctl00_ctl01_loderImg alt=Loading /></div> </div> <script> q=
What am I doing wrong in this HTML code: <html> <head> </head> <body> <div
In the HTML head section: <script type=text/javascript src=Scripts/editScripts.js></script> Just above the </body> tag(closing tag,
If I have an html document whose rough structure is <html> <head> </head> <body
See example: <!DOCTYPE html> <html> <head> <title>language</title> <script type=text/javascript src=http://www.google.com/jsapi> </script> </head> <body> <div
Here is my code html> <head></head> <body> <?php $dir = 'folder/'; $files = scandir($dir);
HTML <!doctype html> <html> <head> </head> <body> <button id=b1 type=button>Show Spoiler</button> <p id=p1 style=display:none>
html <html> <head> <style type="text/css"> body { background-color: transparent; color: white; } </style> </head>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.