Home Tutorial Jquery Change paragraph by clicking button(Toggle effect)

 
 

Share on Google+Share on Google+
Change paragraph by clicking button(Toggle effect)
Posted on: July 28, 2010 at 12:00 AM
Advertisement
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

Advertisement

Related Tags for Change paragraph by clicking button(Toggle effect):


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 28, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com