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

206
Views
Mi atributo deshabilitado no funciona javascript

Después de 50 de longitud, el botón debe desactivarse. Y no funciona, funciona cambiando el color de fondo, pero cuando lo hago btn.disabled = true no pasa nada.

 <div id="main"> <p>Share this on Twitter</p> <form action=""> <textarea></textarea> <div class="buttons"> <span class="limit">100</span> <button class="btn">Tweet</button> </div> </form> </div>

JS:

 const input = document.querySelector("textarea"); const btn = document.querySelector(".btn"); const limit = document.querySelector(".limit"); let max = 50; const updateLimit = () => { limit.textContent = max; input.addEventListener("input", () => { let inputLength = input.value.length; limit.textContent = max - inputLength; if (inputLength > max) { btn.disabled = true; limit.style.color = "red"; } else { btn.disabled = false; limit.style.color = "black"; } }); }; updateLimit();
about 4 years ago · Juan Pablo Isaza
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!