Home > Web Front-end > JS Tutorial > The special effect of matching jquery address bar link and a label link

The special effect of matching jquery address bar link and a label link

不言
Release: 2018-07-02 15:56:07
Original
1609 people have browsed it

This article mainly introduces the special effects of matching jquery address bar links and a tag links. It has certain reference value. Now I share it with you. Friends in need can refer to it

How to get the address with jquery Column parameters, change the address bar style. Next, through this article, I will share with you a summary of the special effect code for matching the jquery address bar link and a tag link. Friends in need can refer to the following

As mentioned in the title, when it appears With this function, after clicking a link, add a style to the link address after the jump, and add a special style by adding class as current.

As shown in the picture: After clicking the HTML css3 jump, add the picture style to it:

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;
        }
     });
}
Copy after login

How to call it?

The following jquery calling code:

$(function(){
  currStyle($("#sidebar .list a"));
})
Copy after login

This achieves the function as shown in the picture.

Javascript and jquery modify the href attribute of a tag

The javascript code is as follows:

document.getElementById("myId").setAttribute("href","www.xxx.com"); 
document.getElementById("myId").href = "www.xxx.com";
Copy after login

jquery: The code is as follows:

$("#myId").attr("href","www.xxx.com");
Copy after login

The above content is the entire content of this article, I hope you like it.

The above is the entire content of this article. I hope it will be helpful to everyone’s study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

jquery ztree implements the right-click collection function

The function of viewing the full text based on jQuery

Select specific tab based on Jquery easyui

##

The above is the detailed content of The special effect of matching jquery address bar link and a label link. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template