You may be a blogger and want to hide and show a div on your WordPress website. Or maybe a web dev enthusiast who just wants to practice this as a mini-module in your web development journey.
Example 1: Hide and Show a Single Div
Example 2: Hide / show multiple div having the same Id (Recommended)
If you want to hide/show multiple div at one go with a single button then we need to modify the code a bit to achieve our goal.
Example 2: Hide and show multiple div having different Id’s
if you are having multiple ids then you need to pass all the id’s of the div into the querySelectorAll() function separated with a comma.
We have created the above pin’s for you to see the work into action.