December 16, 20169 yr Hi, I'm trying to launch one modal from 6 different instances of the same button. As in this fiddle: https://jsfiddle.net...dek/cb9rmchb/2/ It's the same button (ie called bookbtn) which I need to use 6 times on a page to launch a modal with a booking form in it. At the moment I can only launch the modal from the first button????Thanks for any advice.
December 16, 20169 yr document.querySelector only selects one element. To select multiple elements, you should use document.querySelectorAll, which produces a node list. document.querySelector('.bookbox'); // <div class="bookbox"></div> document.querySelectorAll('.bookbox'); // [div.bookbox, div.bookbox]; Please see: document.querySelector & document.querySelectorAll Here is an updated example: https://jsfiddle.net/LyndseyB/cb9rmchb/3/
December 16, 20169 yr Author Thanks again Lyndsey.I really do need to improve my javascript skills and I am slowly doing it on a project by project basis. I wish I could take time out to focus on a js course!
Create an account or sign in to comment