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>