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

234
Views
Javascript - Select element by id name

Normally I select elements with an id via document.getElementById('idName'). But apparently you can also select them by name only 'idName'. I was not aware of this until recently. I wanted to know if this is a "bad practice" to select elements by their idName? I have already used the search engine and found nothing about select by id name. So here is my question now.

enter image description here

 console.log(idName)
<div id="idName">Hello World</div>

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

I believe this is a bad practice because you can get yourself confused and cause conflicts with your own js variables.

over 4 years ago · Santiago Trujillo Report

0

I can't say it's Good or bad But

you should be very careful while using . This can cause many problems So I will recommend use in Small Projects only . (it's My personal recommendation )

Suppose Your JavaScript loads First then it will throw an error and none of the code will work

For more Information

just typing in 'idName' isn’t a “short form” of document.getElementById() It’s a reference to a global variable

over 4 years ago · Santiago Trujillo 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!