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

171
Views
Traté de hacer un sistema simple y divertido con números crecientes y decrecientes con entrada, pero no funciona

Probé el script y funciona bien para las primeras 2 funciones, pero luego, cuando agregué la tercera, la página completa simplemente no funciona. ¿Puedo saber por qué y cómo solucionarlo?

Soy un Javascripter principiante y todavía necesito prácticas, ¿pueden explicarme de alguna manera adecuada para mi nivel?

 let a = 0, b = 1 function inc() { a += b document.getElementById("x").innerHTML = "x" + " " + "=" + " " + a; }; function dec() { a -= b document.getElementById("x").innerHTML = "x" + " " + "=" + " " + a; }; function input() { if (document.getElementById("input").innerHTML == null) { } else { b = Number(document.getElementById("input").innerHTML); }; };
 body { background-color: powderblue; }
 <h1>Online simple Javascript project!</h1> <p id="x">x = 0</p><!-- Result --> <p><br><br>Change the power here!</p><!-- // Description --> <input id="input"><button type="button" onclick="input()">Apply</button><!-- // Button that save your power --> <h2>Click the button to increase x</h2><!-- // Description --> <button type="button" onclick="inc()">Increase</button><!-- // Increase --> <h2>Click the button to decrease x</h2><!-- // Description --> <button type="button" onclick="dec()">Decrease</button><!-- // Decrease -->

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

0

Utilice el valor en lugar de innerHTML para input

 function input() { if (document.getElementById("input").value != null){ b = Number(document.getElementById("input").value); }; };
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!