View Single Post
07-19-2009, 07:28 PM
#6
JulijanAndjelic is offline JulijanAndjelic
JulijanAndjelic's Avatar
Status: I'm new around here
Join date: Jul 2009
Location: Novi Sad, Serbia
Expertise:
Software:
 
Posts: 11
iTrader: 0 / 0%
 

JulijanAndjelic is on a distinguished road

Send a message via ICQ to JulijanAndjelic Send a message via MSN to JulijanAndjelic Send a message via Skype™ to JulijanAndjelic

  Old

Originally Posted by hijax View Post
What I'm struggling with is this...

I would like to have the icon that I hit (makes the div toggle up & down) to switch images when being up and being down(hide).

would I need to append the icon images in javascript within the line ?
or am I no where near?

$(document).ready(function () {
/* $("ul.menu_body li:even").addClass("alt");*/
$('img.menu_head5').click(function () {
$('.entry2').slideToggle('slow'); <--- here?


});
});
I know you solved the problem, just in case somebody else has the same problem...what you are looking for is the callback function.
$('.entry2').slideToggle('slow', function() {
if ($("#myImage").attr("src")=="images/minus.png") {
$("#myImage").attr("src","images/plus.png");
} else {
$("#myImage").attr("src","images/minus.png");
}
})

What we did here:
upon successful slide togle we check if the image is minus, if it is we change it to plus, othervise we change it to minus.
(I wrote the code from head without testing it but it should work, eventually I havent closed some braces...and you need, of course, to change image paths and selectors).

Best regards,
Julijan Andjelic

Reply With Quote