jquery vertical Menu and horizontal menu implementation

Source: Internet
Author: User

1 Creating a verticalandhorizontalmenu.html file

<! Doctype html>


2 Creating a Verticalandhorizontalmenu.css file

Ul,li{    list-style: none;} ul{    padding: 0;    margin: 0;}. Vmain{    width: 150px;    background-image: url ("images/ Toptitle.gif ");     background-repeat: no-repeat;    margin-bottom :  2px;}. Hmain{    width: 150px;    background-image: url ("images/ Toptitle.gif ");     background-repeat: no-repeat;    margin-right:  2px;    float: left;} a{    text-decoration: none;    padding-top: 3px;     padding-bottom: 3px;    padding-left: 20px;     display: block;    width: 130px;}. vmain a,.hmain a{    color:  #ffffff;  &nbSp;  background-image: url ("Images/collapsed.gif");     background-repeat:  no-repeat;    background-position: 3px center;}. vmain li a,.hmain li a{    color:  #000000;     background-image: none;    background-color:  #eeeeee;     border-bottom: 1px solid  #dddddd;}. Vmain li a:hover,.hmain li a:hover{    background-image: url (" Images/linkarrow.gif ");    background-repeat: no-repeat;     background-position: right center;    background-color:  #006666;     color:  #fff;}. Vmain ul,.hmain ul{    display: none;}


3 Creating a Verticalandhorizontalmenu.js file

$ (function () {    $ (". Vmain>a"). Click (function () {         var ulnode=$ (This). Next ("ul");         /* method One */         if (ULNODE.CSS ("display") = = "None") {      &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;ULNODE.CSS ("Display", "block");             /*               OR:              ulnode.show ("normal");// Number (milliseconds), Fast,slow, Normal, and fast              or:              ulnode.slidedown ();              */         }        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 ();         */     });     $ (". Hmain"). Hover (function () {         $ (This). Children ("ul"). Slidedown ("normal");         Changeicon ($ (this). Children ("a"));     },function () {         $ (This). Children ("ul"). Slideup ("normal");         Changeicon ($ (this). Children ("a"));     }); Function changeicon (Mainnode) {    if (Mainnode) {         if (Mainnode.css ("Background-image"). IndexOf ("Collapsed.gif") >=0) {             mainnode.css ("Background-image", "url (' images/expanded.gif ')");         }else{     &Nbsp;      mainnode.css ("Background-image", "url (' images/collapsed.gif ')");         }    }}


4, the operation effect is as follows

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6B/E0/wKioL1U5DXXTVnmpAACNgz6cAXM790.jpg "title=" p1.jpg "alt=" Wkiol1u5dxxtvnmpaacngz6caxm790.jpg "/>




















This article from "It Technology Learning and communication" blog, declined reprint!

jquery vertical Menu and horizontal menu implementation

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.