i'm trying to make the javascript effects show on multiple divs | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

i'm trying to make the javascript effects show on multiple divs

i have two different codes that i'm trying to add class attributes to and use "queryselectorAll & foreach" to loop through the javascript animation so the effects can show on multiple divs but i keep breaking the code please help https://code.sololearn.com/WwK1HtG3CnjZ/?ref=app https://code.sololearn.com/W3OGQSy6Xgjs/?ref=app

5th Apr 2022, 4:46 AM
loop
loop - avatar
1 Answer
+ 1
Pertaining to: https://www.sololearn.com/compiler-playground/WwK1HtG3CnjZ/?ref=app The first issue is the Id attribute. The value of the id attribute must be unique within the HTML document. So, when you copied the div you also copied the same canvas Id. So that broke everything. If you change the ids for the other canvas, you will at least get the first canvas working.
20th Dec 2022, 12:58 AM
Chris Coder
Chris Coder - avatar