JQuery achieves the display and hiding effects of the left-side navigation module.

Source: Internet
Author: User

JQuery achieves the display and hiding effects of the left-side navigation module.

This article describes how jQuery can display and hide the left navigation module. We will share this with you for your reference. The details are as follows:

1. Effect:

2.html code:

<Div class = "content_left"> <div class = "global_module news"> 

3. jQuery code:

/* Expand and close the module * // * 1. in the structure, a node on the <p> element containing the  label needs to be hidden. You can use $ (". module_up_down "). the prev () method is used to obtain the last peer node of the <p> element, and then the slideToggle () animation method is used to make the element shrink up or expand down */$ (function () {$ (". module_up_down "). toggle (function () {var $ self = $ (this); $ self. prev (). slideToggle (600, function () {$ ("img", $ self ). attr ("src", "images/up.gif") ;}, function () {var $ self =$ (this); $ self. prev (). slideToggle (600, function () {$ ("img", $ self ). attr ("src", "images/down.gif ");});})})
/* Expand and close the product tree * // * 1. the <ul> element of the class "m-treeview" has three sub-<li> elements, each sub-<li> element contains the <span> element and <ul> element. When you click the <span> element, the <ul> element of its peers is hidden if it is in the display state. If it is in the hidden state, it is displayed. Therefore, you must first determine whether the <ul> element is displayed, and then perform other operations */$ (function () {$ (". m-treeview> li> span "). click (function () {// note that the sub-selector (>) var $ ul = $ (this) is used ). siblings ("ul"); if ($ ul. is (": visible") {$ (this ). parent (). attr ("class", "m-collapsed"); $ ul. hide ();} else {$ (this ). parent (). attr ("class", "m-expanded"); $ ul. show () ;}return false ;})})

Related Article

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.