Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Modal launch from several buttons

Featured Replies

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.

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/

  • 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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.