jQuery Automatically Highlight Current Page June 30, 2015December 6, 2017 / Javed Ur Rehman jQuery Automatically Highlight Current Page is moved here https://www.allphptricks.com/jquery-automatically-highlight-current-page/ Share this:Tweet Click to share on Reddit (Opens in new window) Reddit Like Loading... Related
I just put this code in top auto content <html> <head> https://code.jquery.com/js/jquery-1.11.3.min.js $( function () { var pathname=(window.location.pathname.match(/[^\/] $/)[0]); $( ‘.navigation a’).each( function() { if ($(this). attr(‘href’)==pathname) { $(this).addClass( ‘active’); } }); }); <style type="text/css"> #wrapper {margin :1px;} .navigation {padding :1px;} .navigation a {color:red; text-decoration:none;} .active{background:yellow; color:#530;} </style> </head> <body> </body> </html> LikeLike Reply
You included incorrect jQuery URL, it is not the correct URL getting 404 error, use the below one. http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js LikeLike Reply
I try this code in wapka it never works.
LikeLike
Have you properly included jQuery library?
LikeLike
I just put this code in top auto content
<html>
<head>
https://code.jquery.com/js/jquery-1.11.3.min.js
$( function () {
var pathname=(window.location.pathname.match(/[^\/] $/)[0]);
$( ‘.navigation a’).each( function() {
if ($(this). attr(‘href’)==pathname)
{
$(this).addClass( ‘active’);
}
});
});
<style type="text/css">
#wrapper {margin :1px;}
.navigation {padding :1px;}
.navigation a {color:red; text-decoration:none;}
.active{background:yellow; color:#530;}
</style>
</head>
<body>
</body>
</html>
LikeLike
You included incorrect jQuery URL, it is not the correct URL getting 404 error, use the below one.
http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js
LikeLike