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
JS 'onclick' no se activará

¿Alguien puede explicar por qué la parte "onclick" no se activa?

 function displayHello() { let helloName = document.getElementByID('helloNameInput').value; // prints out the variable, to the button >> document.getElementByID("helloNameOutput").textContent = helloName }
 <!--Name input--> <div class="mb-3"> <label for="helloNameInput" class="form-label">Name:</label> <input type="text" class="form-control" name="helloNameInput" id="helloNameInput" placeholder="Enter a name" /> </div> <!--Name output--> <p class="lead" id="helloNameOutput"> </p> <!--Display Hello! & Reset buttons--> <div> <button class="btn btn-primary" id="displayHelloButton" onclick="displayHello()">Display Hello!</button> <button class="btn btn-danger" id="clearButton" onclick="clearName()">Clear</button> </div>

PD:

Estoy aprendiendo JS, así que todavía no estoy muy familiarizado con muchas cosas. (Acabamos de terminar las cosas de HTML el semestre pasado)

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

0

no getElementByID . usa getElementById .

 function displayHello() { let helloName = document.getElementById('helloNameInput').value; // prints out the variable, to the button >> document.getElementById("helloNameOutput").textContent = helloName }
 <!--Name input--> <div class="mb-3"> <label for="helloNameInput" class="form-label">Name:</label> <input type="text" class="form-control" name="helloNameInput" id="helloNameInput" placeholder="Enter a name" /> </div> <!--Name output--> <p class="lead" id="helloNameOutput"> </p> <!--Display Hello! & Reset buttons--> <div> <button class="btn btn-primary" id="displayHelloButton" onclick="displayHello()">Display Hello!</button> <button class="btn btn-danger" id="clearButton" onclick="clearName()">Clear</button> </div>

about 4 years ago · Juan Pablo Isaza Report

0

Funciona, acaba de tener un error tipográfico con getElementByID , debería ser getElementById

 function displayHello() { let helloName = document.getElementById('helloNameInput').value; // prints out the variable, to the button >> document.getElementById("helloNameOutput").textContent = helloName }
 <!--Name input--> <div class="mb-3"> <label for="helloNameInput" class="form-label">Name:</label> <input type="text" class="form-control" name="helloNameInput" id="helloNameInput" placeholder="Enter a name" /> </div> <!--Name output--> <p class="lead" id="helloNameOutput"> </p> <!--Display Hello! & Reset buttons--> <div> <button class="btn btn-primary" id="displayHelloButton" onclick="displayHello()">Display Hello!</button> <button class="btn btn-danger" id="clearButton" onclick="clearName()">Clear</button> </div>

about 4 years ago · Juan Pablo Isaza Report

0

En caso de que otros se encuentren con este mismo problema, he subido una captura de pantalla del "registro de cambios de git", que tiene todas las correcciones a lo anterior, para que funcione según lo previsto. ^_^

ingrese la descripción de la imagen aquí ingrese la descripción de la imagen aquí

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!