Multi-level tree menu code example implemented by jquery, jquery tree instance

Source: Internet
Author: User

Multi-level tree menu code example implemented by jquery, jquery tree instance

Multi-level tree menu code example implemented by jquery:
Tree menus have a large number of applications on websites. This is of course because of its unique advantages. First, it can effectively organize data to make the classification clearer, in general, tree menus can be folded, so that more data can be accommodated in a smaller space. The following describes an attribute menu implemented by jquery.
The code example is as follows:

<! DOCTYPE html> 

The above Code meets our requirements and can fold and expand the property menu. The following describes the implementation process.
I. Implementation principle:
1. switch between the folding and expansion icons:
The folding and expansion icons are actually on a background image. When you click the icon, the switching effect is achieved by controlling the position of the background image, for details, refer to the detailed description of CSS background-position positioning.
2. Fold and hide menus:
The folding and hiding of menus mainly controls the hiding and display of the sibling elements of the title element. I will not introduce them here. For more information, see.
Ii. Code comments:
1. $ (document). ready (function () {}). After the document structure is fully loaded, run the code in the function.
2. $ ('. all1'). toggle (function () {}, function () {}), click the element to switch the function execution.
3. $ (this ). removeClass ('all1 '). addClass ('all '). siblings ('. myUl '). slideUp () is a chained call. First, the style class attribute all1 on the currently clicked element is removed, and then the style class attribute all is added to it, then, hide the element whose class attribute value is myUl In its peer element. In one sentence, this Code enables you to click the level-1 tree to hide the level-2 tree.
4. $ (this ). removeClass ('all '). addClass ('all1 '). siblings ('. myUl '). slideDown (). This code is opposite to the above Code. Click the first-level tree to display the second-level number. The following code functions are similar, so we will not introduce them here.
Iii. Related reading:
1. For details about toggle (), refer to the toggle () method section of jQuery.
2. For the removeClass () function, see the removeClass () method section of jQuery.
3. For the addClass () function, see the addClass () method section of jQuery.
4. For details about the siblings () function, refer to the siblings () method section of jQuery.
5. For details about the slideUp () function, refer to jQuery's slideUp () method.
6. For details about the slideDown () function, refer to the slideDown () method section of jQuery.

The original address is: http://www.softwhy.com/forum.php? Mod = viewthread & tid = 11817.

For more information, see: http://www.softwhy.com/jquery/

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.