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

189
Views
Take button value and pass it into modal

I have a site, where I loop through a bunch of data & produce a button for each element.

I have set the button value for each, to be the unique youtube video URL

<button type="button" class="btn btn-outline-primary mb-1" data-bs-toggle="modal" data-bs-target="#Zdq6f4RXJt" value="#Zdq6f4RXJt">Video</button>

I then have a modal for each video. Which is not optimal.

How can I pass the value from the button into the modal?

Thanks a lot

 <div class="modal fade" id="Zdq6f4RXJt" tabindex="-1" role="dialog" aria-hidden="true">
                            <div class="modal-dialog modal-semi-full modal-dialog-centered">
                              <div class="modal-content">
                                <div class="modal-header">
                                        <h5 class="modal-title">Introduction to MongoDB</h5>
                                  <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                                </div>
                                <div class="modal-body">
                                        <iframe width="100%" height="100%" src="https://www.youtube.com/embed/**Zdq6f4RXJt**" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
                                        </div>
                                <div class="modal-footer">
                                  <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
                                </div> 
                              </div>
                            </div> 
                          </div> 
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

add onClick listener to the button and update the modal with a data attribute which can be referred at later point of time inside the modal.

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!