jQuery向下切换箭头' ontoggle'

时间:2014-09-28 21:43:13

标签: javascript jquery html toggle

您好我有以下内容:FIDDLE

它基本上是手风琴切换菜单。我打算做的是在菜单切换打开后将箭头从右侧位置旋转到向下位置。关闭菜单后,我希望箭头向右旋转。我试过通过找到CSS和

来做到这一点
transform: rotate(-90deg)

但是,箭头的位置不会改变。思考?这是<script>

//Dekstop Content
$('.content').each(function () {
    var $accordian = $(this);
    $accordian.find('.view').on('click', function () {
        $accordian.find('.content-body').slideUp();
        $accordian.find('span').css("transform", 'rotate(0deg);');
        if (!$(this).next().is(':visible')) {
            $(this).next().slideDown();
            $(this).find('span').css({"transform": 'rotate(90deg);'})
        }
    });
});

1 个答案:

答案 0 :(得分:1)

.css应如下所示:.css('Property-Name','Value')

试试这段代码:

//Dekstop Content
$('#content').each(function () {
    var $accordian = $(this);
    $accordian.find('.view').on('click', function () {
        $accordian.find('.content-body').slideUp();
        $accordian.find('span').css('transform','rotate(0deg)'); // Changed
        if (!$(this).next().is(':visible')) {
            $(this).next().slideDown();
            $(this).find('span').css('transform', 'rotate(90deg)'); // Changed
        }
    });
});

来自维也纳的问候