JavaScript Tutorial

.toggle()

<!DOCTYPE html>
<html>
<head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script>
        $(document).ready(function(){
          $("button").click(function(){
            $("p").toggle();
          });
        });
    </script>
</head>
<body>
    <p>This is a paragraph.</p>
    <button>Toggle between hide() and show()</button>
</body>
</html>