من با jquery زیاد کار نکردم
//--------------انتخاب خودکار لینکهای بالای صفحه به ازای صفحه جاری
$(document).ready(function () {
$("#headermenu a").each(function () {
var $a = $(this);
var href = $a.attr("href");
if (href && (location.pathname.toLowerCase() == href.toLowerCase())) {
//صفحه جاری را یافتیم
$a.css({
"color": "Yellow",
"border-bottom": "1px solid"
});
}
});
});
یا
if (typeof String.prototype.startsWith != 'function') {
// see below for better implementation!
String.prototype.startsWith = function (str) {
return this.indexOf(str) == 0;
};
}
$(document).ready(function () {
$("#headermenu a").each(function () {
var $a = $(this);
var href = $a.attr("href");
var path = $.trim(location.pathname.toLowerCase());
var menuHref = $.trim(href.toLowerCase());
if (href && (path == menuHref || (menuHref != '/' && path.startsWith(menuHref)))) {
//صفحه جاری را یافتیم
$a.css({
"color": "Yellow",
"border-bottom": "2px solid"
});
}
});
});