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
Alternar la función iframe js no funciona correctamente

Tengo esta función js:

 var iframeShowing = false; async function show() { var iframe1 = document.getElementById('help-popup'); iframe1.style.display = iframeShowing ? 'flex' : 'none'; iframeShowing = !iframeShowing; }

El problema es que necesito hacer clic 2 veces para mostrar el iframe y hacer que funcione correctamente. Después de hacer clic 2 veces, funciona correctamente (cada clic muestra y oculta el iframe). Pruébelo en el sitio web y lo entenderá. Este es el código html:

 <i class="fas fa-question-circle" id="questionmark" onclick="show();" >

Este es el sitio web actual: https://personal-website.krix12.repl.co/ La función mencionada anteriormente se llama cuando se hace clic en el icono de pregunta borrosa. ¿Cómo puedo hacer que funcione en el primer clic?

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

0

Simplemente puede usar DOMTokenList.toggle() para alternar entre flex y none:

 function toggle() { var iframe1 = document.getElementById('help-popup'); iframe1.classList.toggle('hide'); }
 iframe { display: flex; } .hide { display: none; }
 <div><i class="fas fa-question-circle" id="questionmark" onclick="toggle();">?</i></div> <iframe id="help-popup" class="hide"></iframe>

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!