How does jquery obtain the address bar parameters and change the style of the address bar? Next, I will share with you the special effect code Summary of matching the jquery address bar link with the tag link through this article, if you need such a function, click a link and add a style to the link address after the jump, 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 a"));})
In this way, the function is implemented.
Modify the href attribute of tag a in javascript and jquery.
The javascript code is as follows:
document.getElementById("myId").setAttribute("href","www.xxx.com"); document.getElementById("myId").href = "www.xxx.com";
Jquery: the code is as follows:
$("#myId").attr("href","www.xxx.com");
The above content is all the content of this article. I hope you will like it.