The example in this article describes how jQuery implements the highlighting of tags on the current page. Share it with everyone for your reference. The specific implementation method is as follows:
function nav(name, csskey,cssvalue) { var url = window.location.pathname + window.location.search; var v1 = ""; $(name).each(function () { v1 = "/" + $(this).attr("href"); if (v1 == url) { var v2 = $(this).css(csskey, cssvalue); } }) }
Usage is as follows:
<script src="Scripts/commo.js" type="text/javascript"></script> <script type="text/javascript"> window.onload = function () { nav(".top ul li a", "background-color", "rgb(255,89,0)"); } </script>
I hope this article will be helpful to everyone’s jQuery programming.