I am having a problem with this JQuery in ie7, it works perfectly in chrome, firefox, and ie8/9. I’ve scoured the internets to no avail. It just doesn’t want to change the src attribute, which leads me to believe it’s failing at the if test.
var active = '/wp-content/uploads/2012/07/active.png';
var inactive = '/wp-content/uploads/2012/07/inactive.png';
if ($(this).attr('src') == inactive) {
$(this).attr('src', active);
$('.navbutton').not(this).attr('src', inactive);
}
The line below works in ie7, outside of an if test, so i’m not exactly sure what the problem is. Anyone know what’s going on?
$('#navbutton0').attr('src', active);
Try using
$(this).attr('src').indexOf(inactive) >= 0instead as your if test condition. I think I noticed IE7 was sometimes adding extra stuff to the src, such as the full path.