Sharp jquery-2--An example of showing and hiding, mainly reading the wording

Source: Internet
Author: User

Example:, the default does not show all, click the button to switch back and forth, all display is part of the recommended brand highlighting.

$(function(){//The Dom finishes loading and then executes                    varCategory = $ (' ul li:gt (5): Not (: last) ');//Select the li that you want to hide at the beginning, after the sixth Li, and do not include the last LiCategory.hide ();//Hidden                    varTOGGLEBTN = $ (' Div.showmore > A ');//Select the Click Button                    varToggletext = $ ('. ShowMore a span ');//Select the text element in the desired buttonTogglebtn.toggle (function() {category.show (); Toggletext.css ("Background", "#555"). Text ("Thin display"); $(' ul Li '). Filter (": Contains (' Canon '),: Contains (' Sony ')"). AddClass (' promoted ');//Select the brand you want to highlight},function() {category.hide (); Toggletext.css ("Background", "#eee"). Text ("Show All"); $(' ul Li '). Removeclass (' promoted ');//Remove Highlight class});

Sharp jquery-2--An example of showing and hiding, mainly reading the wording

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.