jQuery: Toggling an image when toggling a DIV
Posted
by Wanda
on Stack Overflow
See other posts from Stack Overflow
or by Wanda
Published on 2010-03-17T17:26:46Z
Indexed on
2010/03/17
17:31 UTC
Read the original article
Hit count: 168
Hey guys,
I'm trying to write some jQuery that will toggle DIVs open and closed, and it's working, but I want an arrow that will change to "down" if the DIV is expanded, and "right" if the DIV is collapsed.
What I have so far:
$('.toggleHead').click(function() {
$('#arrow').attr('src', 'images/icons/down.png');
$(this).next().toggle();
return false;
}).next().hide();
Where would I put the other $('#arrow').attr('src', 'images/icons/right.png');
?
Thanks!
© Stack Overflow or respective owner