I'm looking for something similar to this: http://stackoverflow.com/questions/302955/active-navigation-with-jquery-cant-apply-a-default-class-to-anchor
But I'm using images inside a unordered list and I want to detect the current URL and append the img src with _over.jpg to show it being the current page. (no lectures on using BG position please - the client likes this.)
I'm also using this easy hover (jQuery mouseover), which I bet will need to be adjusted...
$(document).ready(function(){
$(".navbar li").each(function(){
var link = $(this).children("a");
var image = $(link).children("img");
var imgsrc = $(image).attr("src");
// add mouseover
$(link).mouseover(function(){
var on = imgsrc.replace(/.jpg$/gi,"_over.jpg");
$(image).attr("src",on);
});
// add mouse out
$(link).mouseout(function(){
$(image).attr("src",imgsrc);
});
});
});