关于多个折叠面板点击隐藏互不影响的实现

 展开效果:

折叠效果

js:

    var show1 = $('.zyu-gjstxx .zyu-hd .span3');
    var height = $('.zyu-gjstxx .zyu-bd');
    var span2 = $('.zyu-gjstxx .zyu-hd .span2');
    console.log(show1);
    let index = $(this).index();
    console.log(index);
    show1.click(function () {
        $(this).parent().next().slideToggle("fast");

        if ($(this).html() == '收起') {
            $(this)[0].innerHTML = '展开';
            $(this).prev().css({ 'transform': 'rotate(180deg)' });
        }
        else {
            $(this)[0].innerHTML = '收起';
            $(this).prev().css({ 'transform': 'rotate(0)' });
        }
    });

  

猜你喜欢

转载自www.cnblogs.com/zaco/p/12205135.html