jquery Address bar link and a tag link matching effect code summary _jquery

Source: Internet
Author: User

As the title said, when this function, click on a link to the jump after the link address to add style, by adding class for current to increase the special style.

As shown in the picture: Click Html+css3 Jump, add to it as Figure style:

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 calling code:

$ (function () {
  Currstyle ($ ("#sidebar. List A"))

This enables the functionality shown in the figure.

JavaScript and jquery Modify the href attribute of a label

The JavaScript code is as follows:

document.getElementById ("MyId"). setattribute ("href", "www.xxx.com"); 

jquery: The code is as follows:

 
 

The above content is the whole content of this article, Hope everybody likes.

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.