G
G
Grep12020-04-27 21:33:36
JavaScript
Grep1, 2020-04-27 21:33:36

How to hide one block and show the second?

There are 2 buttons and 2 blocks, both blocks are initially display:none.
By pressing, with the help of .slideToggle I display these blocks, but I need that conditionally when block two appears, block one is closed (if open) and vice versa. How is it better to do this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill Makarov, 2020-04-28
@kirbi1996

You hang an onclick event on the buttons, and do a check with if as an example, you can check the attribute or properties of the block class

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question