Skip to content
Advertisement

How to Use document.getElementById with Multiple IDs in JavaScript?

i want to change the code of both the button after clicking it work fine when I use single id but when I use multiple id it did not work I am still learning js so any idea will be helpfull

JavaScript
JavaScript

Advertisement

Answer

Here’s an approach, define a function addClickHandlers which takes in an array of elements (each element has an id, icon and text) and then adds click handlers for each element.

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement