I found an outdated script on djangosnippets, that doesn’t work anymore and updated it to work with the latest jquery version.
Feel free to comment with suggestions to improve it.
(function() {
function main() {
var nav = $('.menu ul');
var path = window.location.pathname.split('/').slice(1,-1);
function act(p) {
return nav.not(nav.find('li.active').parent()).find('li>a[href="/'+p+'"]').parent().addClass('active').length;
}
if (path.length)
{
for(; path.length; path.pop())
{
act(path.join('/')+'/');
}
} else
act('');
}
$(document).ready(main);
})()




