Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

167
Views
why queryselector returns the name of the selector and not the content

I am currently following an online class and I can't understand why I don't have the same thing as the teach in my console.

I have an h1 in my HTML, followed by this :

<script type="text/javascript">
    console.log(document.querySelector('h1'));
</script>

I am supposed to get the content of the h1 in my console but it returns me the selector title. I have not found something that could help me in @.. (and just to be sure I tried it on several browsers).

EDIT : I am supposed to get this:

An image showing the tag I'm Mr. JavaScript in the browser console

And i get this:

An image showing an expandable  element in the browser console

FINAL EDIT : Thank you everyone, I believe this is only a matter of browser (didn't work on Chrome and Firefox but ok on Edge).

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

you just need to add the .innerHTML at the end.

<script type="text/javascript">
    console.log(document.querySelector('h1').innerHTML);
</script>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!