Change paragraph by clicking button(Toggle effect)


 

Change paragraph by clicking button(Toggle effect)

In this tutorial, we will discuss about how to change paragraph by clicking button using jQuery.

In this tutorial, we will discuss about how to change paragraph by clicking button using jQuery.

Change paragraph by clicking button(Toggle effect)

In this tutorial, we will discuss about how to change paragraph by clicking button using jQuery. In the above example, a button & paragraph is displaying initially .When we click on button , a new paragraph will be displayed and the old one will hidden by this effect.

jqTogglePara.html 

<!DOCTYPE html>
<html>
<head>
<script src="jquery-1.4.2.js"></script>
</head>
<body>
<button>Toggle</button>
<p>Bye</p>
<p style="display: none">Good Night</p>
<script>

$("button").click(function () {
$("p").toggle();
});
</script>
</body>
</html>

OUTPUT

After clicking "toggle " button :

It will change alternately after every click on" Toggle button".

Download Source Code

Click here to see demo

Ads