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.