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