In this example, we are going to hide and show the text with same button using toggle() function.
<!DOCTYPE html>
<html>
<head>
<title>Welcome to LearnKode - A code learning platform</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script>
$(document).ready(function() {
$(".toggle").click(function() {
$("p").toggle();
});
});
</script>
</head>
<body>
<p>Click to toggle between hide and show of this text</p>
<button class="toggle">Toggle</button>
</body>
</html>