Mit jQuery Um Active Menüpunkt zu markieren

Hier ist ein jQuery-Snippet, das die aktuelle Seite URL überprüfen wird und vergleichen sie es mit den URLs im Menü und wenn sie übereinstimmen wird es eine Klasse, um den Menüpunkt hinzuzufügen.
<script type="text/javascript">
jQuery(document).ready(function($){
// Get current url
// Select an a element that has the matching href and apply a class of 'active'. Also prepend a - to the content of the link
var url = window.location.href;
$('.menu a[href="'+url+'"]').addClass('current_page_item');
});
</script>

Die obige Lösung wird nur für absolute URLs, die nicht auf jeder Website wird funktionieren, wenn sie relative URLs verwenden zu arbeiten.
var url = window.location.href;
// Will only work if string in href matches with location
$('.menu a[href="'+ url +'"]').addClass('active');
// Will also work for relative and absolute hrefs
$('.menu a').filter(function() {
return this.href == url;
}).addClass('active');

Quelle: http://www.paulund.co.uk/use-jquery-to-highlight-active-menu-item
Mit diesem Skript können Sie auch verwenden, um Gambio active Menü

wallpaper-1019588
Kita-Plätze für Mitarbeiter: Gemeinnützigkeit und Steuervorteile im Blick behalten
wallpaper-1019588
Packstation richtig nutzen – das solltest du beachten
wallpaper-1019588
Algarve News vom 21. bis 27. April 2025
wallpaper-1019588
[Test] iPad Pro 13 (M4) + Zubehör