jQuery implements the method of highlighting the current page labels
- 2020-05-12 02:15:24
- OfStack
This article illustrates how jQuery enables the highlighting of current page labels. Share with you 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);
}
})
}
It can be used 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 is helpful for you to design jQuery program.