Javascript: document.querySelector / querySelectorAll issue

Started by Wellwisher, July 01, 2017, 08:06:37 PM

Previous topic - Next topic

Wellwisher

Hello

Re: Menu dropdown/ Javascript: document.querySelector / querySelectorAll issue

I made a simple jsfiddle to showcase the issue. Basically "option 2" is not triggering:

https://jsfiddle.net/5wg9fzq8/

The .JS code is from CodePen by author Alexey Vakulich. I am trying to implement 2x drop down menus in 2x locations on a single page in SMF. I have escaped all the apostrophes but only one of the menus work.

I know the issue relates to using 'document.querySelector' which you can only use once but if you use 'querySelectorAll', this can be used multiple times. I have tried many code variations but I am nowhere close. Hoping someone here can shed some light on the javascript snippet or at least point me in the right direction.

Advertisement: