Home > Article > Web Front-end > How to implement highlighting with jQuery_jquery
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.