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

137
Views
Are DOM elements treated as objects?

Hello I am new to javascript and I came across this code which I don't quite get and the code is

let element = document.querySelector(".some-class")
element.x = "hello world"
console.log(element.x)

And this code logs hello world to the console. So my question is that are the DOM elements treated as objects(because in objects we use the same syntax like obj.color for example.) And what does that x mean in general?

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

0

With element.x you added a attribute to your element object, with just this code, document.querySelector(".some-class") is useless, it would do the same if you just had declared an empty variable element.

However, you can edit the element in the HTML with this syntax, for example

let element = document.querySelector(".some-class");
element.innerHTML = "bb";
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!