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

127
Views
addEventListener on hover but only trigger once?

I have some code that shows a popup when hovering over the .acfef-submit-button element. However, I only want this to happen once. How can I adjust this code to only allow the popup to appear once?

document.addEventListener('DOMContentLoaded', function() {
    let elements = document.querySelectorAll( '.acfef-submit-button' );
    let popupposts = ['6033'];

    elements.forEach(function(e,i){
    e.addEventListener( 'mouseenter', function(){
        elementorProFrontend.modules.popup.showPopup( { id: popupposts[i] } );
    } );
    });
});
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

After the function, add an option object with {once: true}

about 4 years ago · Juan Pablo Isaza Report

0

Use {once: true} so that function run only once :

document.addEventListener('DOMContentLoaded', function() {
    let elements = document.querySelectorAll( '.acfef-submit-button' );
    let popupposts = ['6033'];

    elements.forEach(function(e,i){
    e.addEventListener( 'mouseenter', function(){
        elementorProFrontend.modules.popup.showPopup( { id: popupposts[i] } );
    } );
    });
}, {once: true});
about 4 years ago · Juan Pablo Isaza Report

0

It's a little hacky but setting a viewed boolean would work.

document.addEventListener('DOMContentLoaded', function () {
    let elements = document.querySelectorAll('.acfef-submit-button');
    let popupposts = ['6033'];
    let viewed = false; // or set this in the first loop if you need to

    elements.forEach(function (e, i) {
        e.addEventListener('mouseenter', function () {
            if (viewed === false) {
                elementorProFrontend.modules.popup.showPopup({ id: popupposts[i] });
                viewed = true;
            }
        });
    });
});
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!