본문 바로가기

jscript

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

<!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>


<button>Toggle between hiding and showing the paragraphs</button>


<p>This is a paragraph with little content.</p>

<p>This is another small paragraph.</p>


</body>

</html>