[jQuery] Re: Hover Area -> Change image

2009-08-26 Thread Leonard Martin
Yes, you (wheatstraw) just need to remember that attr('src') returns a string and *not* a reference to the src attribute. On Aug 26, 5:16 pm, amuhlou wrote: > I think keeping the source in a variable is the key here, try this: > > $('li.clickable').hover(function() { >         var newsrc = $(t

[jQuery] Re: Hover Area -> Change image

2009-08-26 Thread amuhlou
I think keeping the source in a variable is the key here, try this: $('li.clickable').hover(function() { var newsrc = $(this).find('img').attr('src').replace ("_off","_over"); $(this).find('img').attr({src: newsrc}); }, function() { var oldsrc = $(this).find('img').attr('s

[jQuery] Re: Hover Area -> Change image

2009-08-26 Thread wheatstraw
That worked, thank you so much! On Aug 26, 11:56 am, Leonard Martin wrote: > You're not actually setting the source once you've replaced it: > > $('li.clickable').hover(function() { >         $(this).find('img').attr('src', $(this).find('img').attr > ('src').replace("_off","_over"));}, function(

[jQuery] Re: Hover Area -> Change image

2009-08-26 Thread wheatstraw
OK! we're close... If I attach this to a variable and echo it out, it give's me the correct string. The _off is replaced with _over and the other way around. As I have it below, on hover, the image will not change, no errors (firebug), just doesn't do anything. $('li.clickable').hover(function()

[jQuery] Re: Hover Area -> Change image

2009-08-26 Thread Leonard Martin
You're not actually setting the source once you've replaced it: $('li.clickable').hover(function() { $(this).find('img').attr('src', $(this).find('img').attr ('src').replace("_off","_over")); }, function() { $(this).find('img').attr('src', $(this).find('img').attr ('src').replace("

[jQuery] Re: Hover Area -> Change image

2009-08-25 Thread amuhlou
children() only works for direct children of an element, so if your img is wrapped in an , it won't find the right element. Try using find() instead: $("li.clickable").hover(function() { $(this).find("img").attr("src", $(this).attr("src").split ("_off").join("_over")); }, function() {

[jQuery] Re: Hover Area -> Change image

2009-08-25 Thread wheatstraw
Thanks but it doesn't seem to work... http://localhost/wrt-demo/images/ projects/boxes/13_off.jpg" alt="Abuja Master Plan" /> http://localhost/wrt-demo/projects/detail/ Abuja-Master-Plan/13">Abuja Master Plan $(".clickable").hover(function() { $(this).children("img").at

[jQuery] Re: Hover Area -> Change image

2009-08-25 Thread Liam Potter
It's because you have targeted the image as the hover area rather then the li, use this instead $("li.clickable").hover(function() { $(this).children("img").attr("src", $(this).attr("src").split("_off").join("_over")); }, function() { $(this).children("img").attr("src", $(thi