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

118
Views
Javascript para inyectar HTML con declaración if

Estoy tratando de crear una función que muestre y oculte un div a través de la inyección de JavaScript. La función se inyecta perfectamente sin el if (condición) como: $("#video-container").load("include/video.html"); pero no se inyecta correctamente con la declaración if. ¿Cómo una declaración if rompe algo como esto?

 var show_video_feed_bool = false; function show_video_feed() { if (show_video_feed_bool == false) { $("#video-container").load("include/video.html"); show_video_feed_bool = true; } if (show_video_feed_bool) { document.getElementById("video-container").innerHTML = ""; show_video_feed_bool = false; } }

vídeo.html

 <div id="container"> <video autoplay="true" id="videoElement"> </video> </div> <script> var video = document.querySelector("#videoElement"); if (navigator.mediaDevices.getUserMedia) { navigator.mediaDevices.getUserMedia({ video: true }) .then(function (stream) { video.srcObject = stream; }) .catch(function (err0r) { console.log("Something went wrong!"); }); } </script>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Probar:

 show_video_feed_bool = false; function show_video_feed() { if (!show_video_feed_bool) { $("#video-container").load("include/video.html"); } else { document.getElementById("video-container").innerHTML = ""; } show_video_feed_bool = !show_video_feed_bool; }
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!