Frameworks| Hibernate| Struts| JSF| JavaFX| Ajax| Spring| DOJO| JDO| iBatis| Questions?

Hot Searches
struts-config.xml  web.xml  Java date format  read/write text file using javascript  ArrayList  Insert Data into Database Using Hibernat  create text file using java  insert data to text file using java  Visual Basic Date and Time Display the t  Create table and insert data by sql quer 

  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments

jQuery Toggle the Div

                         

In this JQuery tutorial we will develop a program that toggle the content of a Div

Steps to develop the Toggle of a Div .

Step 1:

 

 

 

Create a new file (jqrycollapse.html) and add the following code into it:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>JQuery Collapse</title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(function()
{

$("#click_here").click(function(event) {
event.preventDefault();
$("#div1").slideToggle();
});

$("#div1 a").click(function(event) {
event.preventDefault();
$("#div1").slideUp();
});
});
</script>
<style type="text/css">
body {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
color: #666666; 
}
a{color:#993300; text-decoration:none;}
#div1 {
width:70%;
display: none;
padding:5px;
border:2px solid #EFEFEF;
background-color:#FEFEFE;
}
#click_here{

padding:5px;
border:2px solid #FFEFEF;
background-color:#EFEFEF;
}
</style>
</head>
<body>
<input type="button" id="click_here" value="Click Here">

<div id="div1">
<a href="#" class="close">[x]</a>
<p>
Content of a Div Toggle
</p>
</div>
</body>
</html>

Program explanation:

The following code includes the jQuery JavaScript library file:

<script type="text/javascript" src="jquery.js"></script>

The Code

$("#click_here").click(function(event) 

 This function works when generate the click event where id is  "click_here" 

and having correponding style css.

#click_here{

padding:5px;
border:2px solid #FFEFEF;
background-color:#EFEFEF;
}

 

$("#div1").slideToggle();

This function Toggle the Div where id is "div1" and having style css

#div1 {
width:70%;
display: none;
padding:5px;
border:2px solid #EFEFEF;
background-color:#FEFEFE;
}

 

$("#div1 a").click(function(event) 

This function generate a click event on href  link  having id "div1" and having style css.

 

a{color:#993300; text-decoration:none;}
#div1 {
width:70%;
display: none;
padding:5px;
border:2px solid #EFEFEF;
background-color:#FEFEFE;
}

$("#div1").slideUp();

This function close the Div by Sliding  up the Div.

 

 

Check online demo of the application

                         

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Tell A Friend
Your Friend Name

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.