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

151
Views
Event listener on span requires me to refresh the page in order for it to be clickable

I have this problem which I know is a bug, if anyone has had the same problem could you explain it, essentially the span "excla" requires the user to refresh the page before they can click on it, after the user refreshes the page they can click on it how many times they want, I am trying to make it clickable from the get go, does anyone know why this is happening?

<div class="popupz" id="popupx" href="javascript:void(0);" href="javascript:;">
<span class="popuptext" id="myPopup">Content</span>

<span id="excla" class="ddop" onclick="myFunctionz()" style="background-color:#fff;" 
href="javascript:void(0);" href="javascript:;">
!
</span>
</div>
<script>

// When the user clicks on div, open the popup
const element = document.getElementById("excla");
element.addEventListener("click", function() {
var popup = document.getElementById("myPopup");
popup.classList.toggle("show");
});
</script>
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You seem to have a lot of extraneous code. I've trimmed it down to the minimum to show and hide myPopup

You just need to add in some css.

// When the user clicks on div, open the popup
const element = document.getElementById("excla");
element.addEventListener("click", function() {
var popup = document.getElementById("myPopup");
popup.classList.toggle("show");
});
#myPopup
{
visibility:hidden;
}

#myPopup.show
{
visibility:visible;
}
<div class="popupz" id="popupx">
<span class="popuptext" id="myPopup">Content</span>

<span id="excla" class="ddop" style="background-color:#fff;">
!
</span>
</div>


about 4 years ago · Santiago Trujillo 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!