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

138
Views
Javascript: ¿Por qué no puedo usar "esto" con childnodes?
<div id="test" onmouseover="working(this)"> <p>help</p> <p>me</p> </div> <div id="test" onmouseover="not_working(this)"> <p>help</p> <p>me</p> </div>

Cuando uso la primera función (no funciona) no funciona, pero cuando uso la segunda función (funciona) sí.

 function not_working(element){ document.getElementById(element).childNodes[1].innerHTML="succeed";} function working(element){ document.getElementById("test").childNodes[1].innerHTML="succeed";}

Lo siento si me pierdo algo simple, todavía estoy aprendiendo html y solo tengo un conocimiento limitado sobre javascript.

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

0

this es una referencia al elemento a partir del cual se creó el evento (el div en su caso), pero getElementById toma una identificación ( "test" en su caso).

Además, el elemento flotante ya se está pasando en la función como element , por lo que puede hacer lo siguiente:

 function working(element) { element.childNodes[1].innerHTML="succeed" }
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!