D
D
dmitry69962018-02-10 16:26:28
JavaScript
dmitry6996, 2018-02-10 16:26:28

How can I make the container appear when the button is clicked and removed when the button is clicked again?

There is a container:

<div id="nav" class="one">
      <div class"one_s">Привет</div>
  </div>


How to make it appear on the page when you click on the button, and disappear when you click again, etc.?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
dmitry6996, 2018-02-10
@dmitry6996

Cube Cube I
use jquery.
You need to add this container:
How to specify in your example that it is this container that needs to be added / removed on click?

C
Cube, 2018-02-10
@liveunit

If you are using jquery then .toggle() will help.

$("button").click(function() {
  $("div").toggle();
});

A
Andrey Tsvetkov, 2018-02-10
@yellow79

<style>
#hello.hidden{
    display:none
}
</style>
<div id="hello">Привет</div>
<button onclick="document.querySelector('#hello').classList.toggle('hidden')">click</button>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question