Use jquery to achieve vertical menus and horizontal menu effects

Source: Internet
Author: User

1 using jquery to implement vertical menus

1.1 Create the Verticalmenu.html file with the following content:

<!DOCTYPE HTML><HTML><Head Lang="en"> <Meta CharSet="UTF-8"> <Link href="Vertical.CSS"rel="stylesheet"> <Script src="jquery-1. One.2.min.JS"type="text/JavaScript"></Script> <Script type="text/JavaScript"src="Vertical.JS"></Script> <title>Vertical Menu</title></Head><Body><ul> <Li class="Main"> <a href="#">Vertical Menu 1</a> <ul> <Li><a href="#">Sub-Menu 1</a> </Li> <Li><a href="#">Sub-Menu 2</a> </Li> </ul> </Li> <Li class="Main"> <a href="#">Vertical Menu 2</a> <ul> <Li><a href="#">Sub-Menu 1</a> </Li> <Li><a href="#">Sub-Menu 2</a> </Li> </ul> </Li> <Li class="Main"> <a href="#">Vertical Menu 3</a> <ul> <Li><a href="#">Sub-Menu 1</a> </Li> <Li><a href="#">Sub-Menu 2</a> </Li> </ul> </Li></ul></Body></HTML>

1.2 Create the Vertical.css file with the following content:

ul,li{    List-style:none;} ul{    padding:0;    margin:0;}. main{     150px;    Background-image:url ("images/toptitle.gif");    Background-repeat:no-repeat;} a{    Text-decoration:none;    padding-top:3px;    padding-bottom:3px;    padding-left:20px;    Display:block;     120px;}. Main a{    color: #ffffff;    Background-image:url ("images/collapsed.gif");    Background-repeat:no-repeat;    BACKGROUND-POSITION:3PX Center;}. Main Li a{    color: #000000;    Background-image:none;}. Main ul{    Display:none;}

1.3 Create the Vertical.js file with the following content:

$ (function () {$ (". Main>a"). Click (function () {var ulnode=$ ( This). Next ("ul");/ * Method One * /        if(Ulnode.css ("Display")=="None") {Ulnode.css ("Display","Block");/ * OR: Ulnode.show ("normal");//digit (MS), Fast,slow, Normal and fast or: Ulnode.slide            Down (); */}Else{Ulnode.css ("Display","None");/* OR: Ulnode.hide ("normal");            Or: Ulnode.slideup (); */}/ * or Method two: Ulnode.toggle ("normal");//Number (MS), Fast,slow, normal and fast or method three: Ulnode.slidetoggle ()        ; */});});


The results are as follows:

650) this.width=650; "Style=" border-right-0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px "title=" P1 "border=" 0 "alt=" P1 "src=" http://s3.51cto.com/wyfs02/M00/6B/D6/wKiom1U3t8_ H-d6taabekh9krng935.jpg "width=" 174 "height=" 231 "/> 650" this.width=650; "style=" border-right-0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px "title=" snapshot 5 "border=" 0 "alt=" snapshot 5 "src=" http://s3.51cto.com/wyfs02/M01/6B/D6/wKiom1U3t8_ Qjbqmaaauswbczu0508.jpg "width=" 177 "height=" 108 "/>

2 using jquery to achieve horizontal menus


Use jquery to achieve vertical menus and horizontal menu effects

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.