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

234
Views
MicroModal.js pass value

Wondering if you someone could help.

I am using https://micromodal.vercel.app/ as a modal window/popup. Need to pass the data-value of the button into the modal window so I can do show what was clicked.

Below works however, not the first time, if I close the modal window and open it again then it shows the 'data-name' and 'data-value'. There is probably an easier way, hoping someone can assist. Thanks.

<a data-name="One" data-url="https://www.google.com" data-micromodal-trigger="modal-1" class="btn">One</a>
<a data-name="Two" data-url="https://www.yahoo.com" data-micromodal-trigger="modal-1" class="btn">Two</a>
<a data-name="Three" data-url="https://www.bing.com" data-micromodal-trigger="modal-1" class="btn">Three</a>

MicroModal.init({        
    onShow: function() {                      
        const allButtons = document.querySelectorAll(".btn");
        allButtons.forEach(function (button) {
            button.addEventListener("click", () => {
                console.log(button.getAttribute('data-name'))
                console.log(button.getAttribute('data-url'))
            });
        });            
    },
});
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!