Home >Web Front-end >JS Tutorial >How to implement highlighting with jQuery_jquery

How to implement highlighting with jQuery_jquery

WBOY
WBOYOriginal
2016-05-16 16:10:261393browse

The example in this article describes how jQuery implements highlighting. Share it with everyone for your reference. The details are as follows:

The main function codes are as follows:

var v = window.location.pathname;
 $(".hd ul li a").each(function (i) {
 var vherf = $(this).attr("href");
 if (v == vherf) {
  $(".hd ul li").eq(i).addClass("on")
 }
 else {
  $(".hd ul li").eq(i).removeClass("on")
 }
})

When using it, just set the css highlight style of on.

I hope this article will be helpful to everyone’s jQuery programming.

Statement:
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