2010-03-17 92 views
0

我试图写一些jQuery,将切换DIV打开和关闭,它的工作,但我想要一个箭头,将更改为“向下”,如果DIV展开,如果DIV崩溃,则为“正确”。jQuery:切换图像时切换DIV

我有什么至今:

$('.toggleHead').click(function() { 
    $('#arrow').attr('src', 'images/icons/down.png'); 
    $(this).next().toggle(); 
    return false; 
    }).next().hide(); 

我会在哪里把其他$('#arrow').attr('src', 'images/icons/right.png');

谢谢!

回答

0

On #arrow - 您可以使用.toggleClass('open'),它将添加/删除'open'类。

然后在你的CSS中,你可以为.open设置一个背景图像,它将覆盖'down'箭头。

我有类似

$('.accordion-multi h2').click(function() { 
    $(this).next().slideToggle('normal'); 
    $(this).toggleClass('open'); 
    return false; 
}).next().hide();