Gexuma Posted May 20, 2021 Share Posted May 20, 2021 I've been using a gallery based on this tutorial https://www.w3schools.com/howto/howto_js_slideshow_gallery.asp, and it works pretty well, but now I've tried to put two on one page and discovered that this doesn't work, as the variables become shared by both. This leads to them not being independent of one another. I've been trying to figure out a way to do this without creating new sets of variables and classes for each new slideshow on the same page, but I've had no luck. How would I go about efficiently making multiple slideshows? Link to comment Share on other sites More sharing options...
niche Posted May 20, 2021 Share Posted May 20, 2021 (edited) Please post the relevant part of your code. Else, we'd just be guessing. Edited May 20, 2021 by niche Link to comment Share on other sites More sharing options...
Ingolme Posted May 20, 2021 Share Posted May 20, 2021 There's no need to show the code that he wrote, it's the code that is on the tutorial page: https://www.w3schools.com/howto/howto_js_slideshow_gallery.asp The topic is asking how to put two of them on the page at the same time without duplicating the Javascript. I've answered this one already. The problem can be solved by attaching events using Javascript instead of as an HTML attribute. 1 Link to comment Share on other sites More sharing options...
niche Posted May 21, 2021 Share Posted May 21, 2021 Didn’t know you already answered the question. I thought they altered the code based on the tuit. Link to comment Share on other sites More sharing options...
Gexuma Posted May 22, 2021 Author Share Posted May 22, 2021 On 5/21/2021 at 11:58 AM, Ingolme said: There's no need to show the code that he wrote, it's the code that is on the tutorial page: https://www.w3schools.com/howto/howto_js_slideshow_gallery.asp The topic is asking how to put two of them on the page at the same time without duplicating the Javascript. I've answered this one already. The problem can be solved by attaching events using Javascript instead of as an HTML attribute. Thanks for the answer, I'll give that a go. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now