Toggle between hiding and showing the <p> element when you click on the "Toggle" button. - Javascript jQuery

Javascript examples for jQuery:Hide

Description

Toggle between hiding and showing the <p> element when you click on the "Toggle" button.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(function(){
        $("p").toggle();
    });/*from   ww  w  . j  a  v a  2s .c  om*/
});
</script>
</head>
<body>

<button>Toggle</button>

<p>This is a paragraph.</p>

</body>
</html>

Related Tutorials