jQuery implements the method of highlighting

  • 2020-05-12 02:15:28
  • OfStack

This article demonstrates an example of how jQuery can be highlighted. Share with you for your reference. The details are as follows:

The main functional 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")
 }
})

You can set the css highlighted part style of on when you use it.

I hope this article has helped you with your jQuery programming.


Related articles: