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

166
Views
La función simple de JavaScript no pasará la variable para identificar la identificación del elemento

No puedo entender por qué el siguiente código no funcionará:

 function popups(m) { var popup = document.getElementById(m); popup.classList.toggle("show"); }
 .popup { position: relative; display: inline-block; cursor: pointer; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } .popup .popuptext { visibility: hidden; width: 160px; background-color: #555; color: #fff; text-align: center; border-radius: 6px; padding: 8px 0; position: absolute; z-index: 1; bottom: 125%; left: 50%; margin-left: -80px; } .popup .popuptext::after { content: ""; position: absolute; top: 100%; left: 50%; margin-left: -5px; border-width: 5px; border-style: solid; border-color: #555 transparent transparent transparent; } .popup .show { visibility: visible; -webkit-animation: fadeIn 1s; animation: fadeIn 1s; } @keyframes fadeIn { from {opacity: 0;} to {opacity:1 ;} }
 <div class="popup" onclick="popups(myPopup)">Click me to toggle the popup! <span class="popuptext" id="myPopup">A Simple Popup!</span> </div>

Estoy bastante seguro de que el error está dentro de javascript. Cuando lo cambio a lo siguiente, entonces funciona totalmente. Entonces, por alguna razón, no pasará mi variable m para identificar la identificación del elemento ...

 function popups() { var popup = document.getElementById("myPopup"); popup.classList.toggle("show"); }

¿Algún buen codificador que pueda ayudarme, por favor?

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!