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

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
jQuery Drop Down Menu 
 

In this JQuery tutorial we will develop a program to make Drop Down menu

 

jQuery Drop Down Menu

                         

In this JQuery tutorial we will develop a program  to make Drop Down menu

Steps to develop the Drop Down menu .

Step 1:

 

 

 

 

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

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>jQuery  Drop Down Menu</title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#van-one li").hover(
function(){ $("ul", this).fadeIn("slow"); }, 
function() { } 
);
if (document.all) {
$("#van-one li").hoverClass ("sfHover");
}
});

$.fn.hoverClass = function(c) {
return this.each(function(){
$(this).hover( 
function() { $(this).addClass(c); },
function() { $(this).removeClass(c); }
);
});
}; 
</script>

<style type="text/css">

/* vanigation */
.van, .van ul { 
list-style: none;
margin: 0;
padding: 0;
}

.van {
font-family: Arial, Helvetica, sans-serif;
z-index: 100;
position: relative;
}
.van li {
border-left: 1px solid #000;
float: left;
margin: 0;
padding: 0;
position: relative;
}
.van li a, .van li a:link, .van li a:active, .van li a:visited {
font: bold 1.22em/25px Arial, Helvetica, sans-serif;
background: #EFEFEF;
color: #ff0000;
display: block;
padding: 0 9px;
text-transform: lowercase;
text-decoration: none;
}

.van li a:hover {
background: #ccc;
color: #000; 

}
#van-one li:hover a, 
#van-one li.sfHover a {
background: #ccc;
color: #000;
}
#van-one li:hover ul a, 
#van-one li.sfHover ul a {
background: #F0ff0f;
color: #000000; 
}
#van-one li:hover ul a:hover, 
#van-one li.sfHover ul a:hover {
background: #ccc;
color: #000; 
}

.van ul {
background: #565656;
border-bottom: 1px solid #000;
list-style: none;
margin: 0;
width: 100px;
position: absolute;
top: -999em;
left: -1px;
}
.van li:hover ul,
.van li.sfHover ul {
top: 25px;
}
.van ul li {
border: 0;
float: none;
}
.van ul a {
border: 1px solid #000;
border-bottom: 0;
padding-right: 20px;
width: 80px;
white-space: nowrap;
}
.van ul a:hover {
background: #ccc;
color: #000;
}
</style>
</head>
<body>

<ul id="van-one" class="van">
<li>

<a href="#item1">item A</a>
<ul>
<li><a href="#itemA1">item A1</a></li>
<li><a href="#itemA2">item A2</a></li>
<li><a href="#itemA3">item A3</a></li>
<li><a href="#itemA4">item A4</a></li>

</ul>
</li>
<li>
<a href="#item2">item B</a>
<ul>
<li><a href="#itemB1">item B1</a></li>
<li><a href="#itemB2">item B2</a></li>

</ul>
</li>
<li>
<a href="#item3">item C</a>
<ul>
<li><a href="#itemC1">item C1</a></li>
<li><a href="#itemC2">item C2</a></li>

</ul>
</li>

</ul>

<br clear="all" />

</body>
</html>

Program explanation:

The following code includes the jQuery JavaScript library file:

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

The Code

$("#van-one li").hover

 This function works when  generate an hover event and having correponding style css.

van li a:hover {
background: #ccc;
color: #000; 

}
#van-one li:hover a, 
#van-one li.sfHover a {
background: #ccc;
color: #000;
}
#van-one li:hover ul a, 
#van-one li.sfHover ul a {
background: #F0ff0f;
color: #000000; 
}
#van-one li:hover ul a:hover, 
#van-one li.sfHover ul a:hover {
background: #ccc;
color: #000; 
}

 

 

we using  ul (unordered list) and impelement a style on it.

 

 

Check online demo of the application

                         

» View all related tutorials
Related Tags: php jquery c query jsp ide dom browser server data asp script random replace user get display ip tutorial ria

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 

Current Comments

1 comments so far (
post your own) View All Comments Latest 10 Comments:

sir
i wannna ask u that suppose i have a drop down list of 10 things n i have 2 select a particular
now what should be the coding to perform this so that it can connect to my database n result could reflect thanks

Posted by ASHISH on Thursday, 12.11.08 @ 03:51am | #82642

Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

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 | Flex 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.