Jquery address bar link matching special effect code Summary (2), jquery special effect code

Source: Internet
Author: User

Jquery address bar link matching special effect code Summary (2), jquery special effect code

As described in, when such a function appears,Click a link to add a style to the link address after the jumpTo add a special style by adding class as current.

: Click HTML + css3 to jump to and add a style to it:

The js Code is as follows:

Var currUrl = window. location. href; var currStyle = function (links) {links. each (function () {var url = $ (this ). attr ('href '); if (currUrl. indexOf (url )! =-1) {$ (this). addClass ("current"); return false ;}});}

 

How to call it? The following jquery call code:

$ (Function () {currStyle ($ ("# sidebar. list "));})

 

In this way, the function is implemented.

 

Author: rainbow after the storm

Source: http://www.cnblogs.com/moqiutao/

If you think this article is helpful to your learning, please provide more support and encouragement.

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.