Button to simultaneously show / hide multiple divs

I would like to have one button that, when clicked, displays several divs at once (3 or more), and then when pressed again hides the div. I found answers for displaying multiple divs one at a time, but I would like all divs to pop up at the same time and hide at the same time from one button. Divas will be decorated in different ways. I'm sorry if this has already been answered and thanks in advance for any answers

+4
source share
3 answers

Why don't you tell the hiddenDiv class for all sections that need to be hidden and use

 $('#hideButton').click(function() { $('.hiddenDiv').toggle(); }); 
+3
source

Use this script:

 $('#button-id').click(function(e) { $('#id1, #id2').toggle(); e.preventDefault(); }); 
0
source

Or you can use plain javascript (if you don't like jQuery) and call a double (or more) function to hide the html elements. Something like that:

 <button onclick="divHideShow('divC');divHideShow('divD');">Click me</button> 

Of course, divHideShow is a function that hides the div element. So call above hide div and divD. For detailed instructions, see Show or hide multiple sections .

0
source

All Articles