简体   繁体   English

jQuery向下切换箭头“切换”

[英]jQuery toggle arrow down 'ontoggle'

Hi I have the following: FIDDLE 嗨,我有以下内容: FIDDLE

It's essentially an accordion toggle menu. 本质上是手风琴切换菜单。 What I am trying to do is rotate the arrow from the right position to a downward position once the menu has been toggled open. 我要尝试的是一旦菜单已打开打开,就将箭头从正确的位置旋转到向下的位置。 Upon the menu closing I would like the arrow to rotate back its rightward position. 菜单关闭后,我希望箭头向右旋转。 I have tried doing it by finding the CSS and 我尝试通过找到CSS和

transform: rotate(-90deg)

However, the position of the arrow does not change. 但是,箭头的位置不会改变。 Thoughts? 思考? This is the <script> 这是<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);'})
        }
    });
});

The .css should look like this: .css('Property-Name','Value') .css应该如下所示: .css('Property-Name','Value')

Try this code: 试试这个代码:

//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
        }
    });
});

Greetings from Vienna 维也纳的问候

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM