2015-10-29 115 views
2

我一直在尝试通过向jquery语句添加css类来制作箭头旋转。这用于显示/隐藏标签,这将允许我根据箭头显示哪一个是打开的。Jquery添加/删除类不起作用

我有这个工作在前一页,当我有3个标签,但我在新的页面上添加了第4个标签,现在它不会工作。

这是打印我的console.log,并没有返回任何错误,所以即时通讯努力理解我做错了什么。

这是JQuery的:

<script> 
    $("#border-information").click (function() { 
     $("#showhide-information").show(500); 
     $(".arrowup").addClass("turn"); 
     }); 

    $("#border-resources").click (function() { 
     $("#showhide-resource").show(500); 
     $(".arrowdown2").addClass("turn"); 
     }); 

    $("#border-comment").click (function() { 
     $("#showhide-comment").show(500); 
     $(".arrowdown3").addClass("turn"); 
    }); 

    $("#border-timelapse").click (function() { 
     $("#showhide-timelapse").show(500); 
     $(".arrowdown4").addClass("turn"); 
    }); 

var showHide="one"; 


$("#border-information").click (function() { 
    showHide="one"; 
    changePanel(); 
}); 

$("#border-resources").click (function() { 
    showHide="two"; 
    changePanel(); 
}); 

$("#border-comment").click (function() { 
    showHide="three"; 
    changePanel(); 
}); 

$("#border-timelapse").click (function() { 
    showHide="four"; 
    changePanel(); 
}); 

function changePanel(){ 
    switch(showHide){ 

     case "one": 
     //My code 
     console.log("my code 1 is working"); 
     $("#showhide-comment").hide(500); 
     $("#showhide-resource").hide(500); 
     $("#showhide-timelapse").hide(500); 
     $(".arrowdown2").removeClass("turn"); 
     $(".arrowdown3").removeClass("turn"); 
     $(".arrowup").removeClass("turn"); 
     $(".arrowdown4").removeClass("turn"); 
     break; 

     case "two": 
     //My code 
     console.log("my code 2 is working"); 
     $("#showhide-information").hide(500); 
     $("#showhide-comment").hide(500); 
     $("#showhide-timelapse").hide(500); 
     $(".arrowup").addClass("turn"); 
     $(".arrowdown3").removeClass("turn"); 
     $(".arrowdown4").removeClass("turn"); 
     break; 

     case "three": 
     //My code 
     console.log("my code 3 is working"); 
     $("#showhide-information").hide(500); 
     $("#showhide-resource").hide(500); 
     $("#showhide-timelapse").hide(500); 
     $(".arrowup").addClass("turn"); 
     $(".arrowdown2").removeClass("turn"); 
     $(".arrowdown4").removeClass("turn"); 
     break; 

     case "four": 
     //My code 
     console.log("my code 4 is working"); 
     $("#showhide-information").hide(500); 
     $("#showhide-resource").hide(500); 
     $("#showhide-comment").hide(500); 
     $(".arrowup").addClass("turn"); 
     $(".arrowdown2").removeClass("turn"); 
     $(".arrowdown3").removeClass("turn"); 
     break; 

     default: 
     //My default code 
    } 
} 
; 
</script> 

这是CSS类使用即时通讯:

 #wrapper { 
     background-color: #1B9AA1; 
     width: 100%; 
     overflow:hidden; 
    } 

    body { 
     margin: 0; 
     font-family: Arial; 
     height: 100%; 
     width: 100%; 
    } 

    .container { 
     background-color: #1B9AA1; 
     width:100%; 
    } 

    #sidebar { 
     width: 100%; 
     background-color: #1B9AA1; 
     overflow: hidden; 
     height: 70%; 
    } 

    #resources-text { 
     font-size: 26px; 
     font-weight: none; 
     display: inline-block; 
     padding-left: 3px; 
     color: white; 
    } 

    #information-text { 
     font-size: 26px; 
     font-weight: none; 
     padding-left: 36px; 
     color: white; 
     margin: 0; 
     float: left; 
     display: inline-block; 
    } 

    .description { 
     font-size: 13.5px; 
     color: white; 
     display: inline-block; 
     padding-left: 3px; 
    } 

    .region { 
     font-size: 13.5px; 
     color: white; 
     padding-left: 60px; 
    } 

    #resources { 
     color: white; 
     font-size: 26px; 
     padding-left: 100px; 
     font-weight: none; 
     margin: 0; 
     margin-top: 1px; 
    } 

    .resource-body { 
     color: white; 
     font-size: 13.5px; 
     padding-left: 105px; 
    } 

    #timelapse { 
     color: white; 
     font-size: 26px; 
     margin: 0; 
     padding-left: 100px; 
    } 

    .timelapse-body { 
     color: white; 
     font-size: 13.5px; 
     padding-left: 105px; 
    } 

    .dacast { 
     float: left; 
     width: 47%; 
     background-color: black; 
     clear: after; 
     margin-left: 40px; 
     margin-bottom: 20px; 
    } 

    .slides { 
     margin-left: 40px; 
     display: inline-block; 
     margin-right: 20px; 
     width: 47%; 
     position: relative; 
     z-index: 0; 
    } 

    .comment-title { 
     margin: 0; 
     margin-top: 1px; 
    } 

    .comment-title { 
     color: white; 
     font-size: 26px; 
     font-weight: none; 
    } 

    #showhide-information { 
     padding-left: 105px; 
    } 

    .comment-display { 
     width: 90%; 
     height: 417px; 
     border: none; 
     background-color: white; 
     max-height: 417px; 
     overflow-y: scroll; 
     margin: auto; 
    } 

    .comment-comment { 
     width: 55%; 
     height: 40px; 
     margin-left: 4%; 
     float: left; 
     display: inline-block; 
     border: none; 
     border-radius: 10px 10px 10px 10px; 
    } 

    .indent { 
     padding-left: 15px; 
    } 

    .comment-button { 
     width: 30%; 
     margin-right: 4%; 
     float: right; 
     display: inline-block; 
     height: 40px; 
     color: black; 
     font-weight: none; 
     background-color: white; 
     padding: 0; 
     border: none; 
     border-radius: 10px 10px 10px 10px; 
    } 

    .livestream { 
     background-color: #1B9AA1; 
    } 

    #showhide-resource { 
     display: none; 
    } 

    #showhide-comment { 
     display: none; 
    } 

    #showhide-timelapse { 
     display: none; 
    } 

    .pdf { 
     height: 20px; 
    } 

    .arrowup { 
     float: left; 
     display: inline-block; 
     padding-left: 40px; 
    } 

    .arrowdown2 { 
     float: left; 
     display: inline-block; 
     padding-left: 40px; 
    } 

    .arrowdown3 { 
     float: left; 
     display: inline-block; 
     padding-left: 40px; 
    } 

    .arrowdown4 { 
     float: left; 
     display: inline-block; 
     padding-left: 40px; 
    } 

    #border-information { 
     border-width: 2px 0px 2px 0px; 
     border-color: white; 
     border-style: solid; 
     margin: 0; 
     margin-top: 1px; 
     height: 26px; 
     width: 100%; 
     cursor: pointer; 
    } 

    #border-resources { 
     border-width: 2px 0px 2px 0px; 
     border-color: white; 
     border-style: solid; 
     margin: 0; 
     margin-top: 1px; 
     height: 26px; 
     width: 100%; 
     cursor: pointer; 
    } 

    #border-comment { 
     border-width: 2px 0px 2px 0px; 
     border-color: white; 
     border-style: solid; 
     margin: 0; 
     margin-top: 1px; 
     height: 26px; 
     width: 100%; 
     cursor: pointer; 
    } 

    #border-timelapse { 
     border-width: 2px 0px 2px 0px; 
     border-color: white; 
     border-style: solid; 
     margin: 0; 
     margin-top: 1px; 
     height: 26px; 
     width: 100%; 
     cursor: pointer; 

    .turn { 
     transform: rotate(180deg); 
     -o-transform: rotate(180deg); 
     -ms-transform: rotate(180deg); 
     -moz-transform: rotate(180deg); 
     -webkit-transform: rotate(180deg); 
    } 

如这里要求的是HTML:

<body> 

    <div class="container"> 
    <div class="livestream"> 
    <video id="myvideo" class="dacast" height="540px" controls> 
    <source src="https://s3-eu-west-1.amazonaws.com/icevideos/140520+Stalbans+Construction+2025/140520.STALBANS.Contruction2025.HIGH.mp4"></source> 
    </video> 
    </div> 
    <a class="overlay"></a> 
    <div class="powerpoint"> 
    <iframe class="slides" src="https://docs.google.com/presentation/d/1lbTjJ5q4fr1X4rgryWEAmkq-WuWJIoseU7Q1NyqXc44/embed?start=false&loop=false&delayms=3000" frameborder="0" height="540px" allowfullscreen="true" mozallowfullscreen="true" webkitallowfullscreen="true"></iframe> 
    </div> 
    <div class="sidebar-background"> 
    <div id="sidebar"> 
     <div class="information"> 
     <div id="border-information"> 
    <img src="http://cpdonline.tv/ice-events/arrowUp.png" class="arrowup" height="26px"><p id="information-text">About this event</p> 
    </div> 
    <div id="showhide-information" class="panels"> 
    <span class="region"> 
     <p class="event-float">Event Date - 05/11/2015</p> 
     <p>Event Time: 17:30 - 19:30 <br> 


     <p>Speakers: <br> 

    <span class="indent"><strong> - Cath Schefer</strong> - UK Managing Director, MWH</span><br> 
    <span class="indent"><strong> - Professor David Kennedy</strong> - Deputy Director of the Cardiff School of Engineering and professor of Structural Engineering, Cardiff University</span></br> 
    <span class="indent"><strong> - Alun Davies</strong> - Business Executive, Alun Griffiths Contractors Ltd</span></br> 
    <span class="indent"><strong> - Dawn Turner</strong> - Head of Pension Fund Management, Environment Agency</span> 

    </p> 


    <span class="description" name="information"> 
     <p> 
      Presentations will be given on our four strategic themes of; 
<br /> 
<span class="indent">- Resilience <br /></span> 
<span class="indent">- Urbanisation <br /></span> 
<span class="indent">- Industry Transformation <br /> </span> 
<span class="indent">- Resource Scarcity</span> 
      <br /> 
      </p> 

<span class="indent">- London</p> 
    </span> 
<br /> 

    </div> 
      </div> 
    <div> 
    <div id="border-resources"> 
    <img src="http://cpdonline.tv/ice-events/arrowDown.png" class="arrowdown2" height="26px"><p id="resources">Resources</p> 
    </div> 
    <div id="showhide-resource"> 
    <div class="resource-body" name="resources"> 
    <p>Additional resources available to go with this lecture:</p> 
    <p class="indent"> - <img class="pdf" src="/new.cpd/ice-events/livestream/img/pdf.png"> This is a pdf.pdf</p> 
    </div> 
    </div> 
    </div> 

    <div> 
    <div id="border-timelapse"> 
    <img src="http://cpdonline.tv/ice-events/arrowDown.png" class="arrowdown4" height="26px"><p id="timelapse">Timelapse</p> 
    </div> 
    <div id="showhide-timelapse"> 
    <div class="timelapse-body" name="timelapse"> 
    <br> 
    <div id="jump">10:00 - This is something</div> 
    <br> 
    <div id="jump2">20:00 - This is something</div> 
    <br> 

    </div> 
    </div> 
    </div> 

    <div id="border-comment"> 

    <div id="comments"> 
    <p class="comment-title"> 
    <img src="http://cpdonline.tv/ice-events/arrowDown.png" class="arrowdown3" height="26px"><p id="timelapse">Live Chat</p> 
    </p> 
    </div> 
    </div> 
    <div id="showhide-comment"> 

    <p>ebfgksbgjklsdbghklsg</p> 
     </div> 
    <br 
    </div> 

任何建议将高度赞赏!

+2

需要看HTML – Dhunt

+0

包括你的HMTL兄弟。 – bot

+0

可能是你没有正确包含jQuery,所以只有'console.log'才能工作。但我们真的需要看到HTML以便给出任何一种很好的答案。 –

回答

0

请尝试使用以下代码。我相信它会工作,按您的需要:

修改了HTML一点:

<img src="http://cpdonline.tv/ice-events/arrowDown.png" class="arrowup turn" height="26px"><p id="information-text">About this event</p> 

增加了turn类在默认情况下并用相同的arrowDown.png而不是向上箭头。

另外}在倒数第二个CSS样式表中丢失。 看看可运行的代码片段。

$("#border-information").click (function() { 
 
     showHide="one"; 
 
     changePanel(); 
 
     $(".turn").removeClass("turn"); 
 
     $(".arrowup").addClass("turn"); 
 
     $("#showhide-information").show(500); 
 
    }); 
 

 
    $("#border-resources").click (function() { 
 
     showHide="two"; 
 
     changePanel(); 
 
     $(".turn").removeClass("turn"); 
 
     $(".arrowdown2").addClass("turn"); 
 
     $("#showhide-resource").show(500); 
 

 
    }); 
 

 
    $("#border-comment").click (function() { 
 
     showHide="three"; 
 
     changePanel(); 
 
     $(".turn").removeClass("turn"); 
 
     $(".arrowdown3").addClass("turn"); 
 
     $("#showhide-comment").show(500); 
 
    }); 
 

 
    $("#border-timelapse").click (function() { 
 
     showHide="four"; 
 
     changePanel(); 
 
     $(".turn").removeClass("turn"); 
 
     $(".arrowdown4").addClass("turn"); 
 
     $("#showhide-timelapse").show(500); 
 
    }); 
 

 
var showHide="one"; 
 

 
function changePanel(){ 
 
    switch(showHide){ 
 

 
     case "one": 
 
     //My code 
 
     console.log("my code 1 is working"); 
 
     $("#showhide-comment").hide(500); 
 
     $("#showhide-resource").hide(500); 
 
     $("#showhide-timelapse").hide(500); 
 
     break; 
 

 
     case "two": 
 
     //My code 
 
     console.log("my code 2 is working"); 
 
     $("#showhide-information").hide(500); 
 
     $("#showhide-comment").hide(500); 
 
     $("#showhide-timelapse").hide(500); 
 
     break; 
 

 
     case "three": 
 
     //My code 
 
     console.log("my code 3 is working"); 
 
     $("#showhide-information").hide(500); 
 
     $("#showhide-resource").hide(500); 
 
     $("#showhide-timelapse").hide(500); 
 
     break; 
 

 
     case "four": 
 
     //My code 
 
     console.log("my code 4 is working"); 
 
     $("#showhide-information").hide(500); 
 
     $("#showhide-resource").hide(500); 
 
     $("#showhide-comment").hide(500); 
 
     break; 
 

 
     default: 
 
     //My default code 
 
    } 
 
}
#wrapper { 
 
     background-color: #1B9AA1; 
 
     width: 100%; 
 
     overflow:hidden; 
 
    } 
 

 
    body { 
 
     margin: 0; 
 
     font-family: Arial; 
 
     height: 100%; 
 
     width: 100%; 
 
    } 
 

 
    .container { 
 
     background-color: #1B9AA1; 
 
     width:100%; 
 
    } 
 

 
    #sidebar { 
 
     width: 100%; 
 
     background-color: #1B9AA1; 
 
     overflow: hidden; 
 
     height: 70%; 
 
    } 
 

 
    #resources-text { 
 
     font-size: 26px; 
 
     font-weight: none; 
 
     display: inline-block; 
 
     padding-left: 3px; 
 
     color: white; 
 
    } 
 

 
    #information-text { 
 
     font-size: 26px; 
 
     font-weight: none; 
 
     padding-left: 36px; 
 
     color: white; 
 
     margin: 0; 
 
     float: left; 
 
     display: inline-block; 
 
    } 
 

 
    .description { 
 
     font-size: 13.5px; 
 
     color: white; 
 
     display: inline-block; 
 
     padding-left: 3px; 
 
    } 
 

 
    .region { 
 
     font-size: 13.5px; 
 
     color: white; 
 
     padding-left: 60px; 
 
    } 
 

 
    #resources { 
 
     color: white; 
 
     font-size: 26px; 
 
     padding-left: 100px; 
 
     font-weight: none; 
 
     margin: 0; 
 
     margin-top: 1px; 
 
    } 
 

 
    .resource-body { 
 
     color: white; 
 
     font-size: 13.5px; 
 
     padding-left: 105px; 
 
    } 
 

 
    #timelapse { 
 
     color: white; 
 
     font-size: 26px; 
 
     margin: 0; 
 
     padding-left: 100px; 
 
    } 
 

 
    .timelapse-body { 
 
     color: white; 
 
     font-size: 13.5px; 
 
     padding-left: 105px; 
 
    } 
 

 
    .dacast { 
 
     float: left; 
 
     width: 47%; 
 
     background-color: black; 
 
     clear: after; 
 
     margin-left: 40px; 
 
     margin-bottom: 20px; 
 
    } 
 

 
    .slides { 
 
     margin-left: 40px; 
 
     display: inline-block; 
 
     margin-right: 20px; 
 
     width: 47%; 
 
     position: relative; 
 
     z-index: 0; 
 
    } 
 

 
    .comment-title { 
 
     margin: 0; 
 
     margin-top: 1px; 
 
    } 
 

 
    .comment-title { 
 
     color: white; 
 
     font-size: 26px; 
 
     font-weight: none; 
 
    } 
 

 
    #showhide-information { 
 
     padding-left: 105px; 
 
    } 
 

 
    .comment-display { 
 
     width: 90%; 
 
     height: 417px; 
 
     border: none; 
 
     background-color: white; 
 
     max-height: 417px; 
 
     overflow-y: scroll; 
 
     margin: auto; 
 
    } 
 

 
    .comment-comment { 
 
     width: 55%; 
 
     height: 40px; 
 
     margin-left: 4%; 
 
     float: left; 
 
     display: inline-block; 
 
     border: none; 
 
     border-radius: 10px 10px 10px 10px; 
 
    } 
 

 
    .indent { 
 
     padding-left: 15px; 
 
    } 
 

 
    .comment-button { 
 
     width: 30%; 
 
     margin-right: 4%; 
 
     float: right; 
 
     display: inline-block; 
 
     height: 40px; 
 
     color: black; 
 
     font-weight: none; 
 
     background-color: white; 
 
     padding: 0; 
 
     border: none; 
 
     border-radius: 10px 10px 10px 10px; 
 
    } 
 

 
    .livestream { 
 
     background-color: #1B9AA1; 
 
    } 
 

 
    #showhide-resource { 
 
     display: none; 
 
    } 
 

 
    #showhide-comment { 
 
     display: none; 
 
    } 
 

 
    #showhide-timelapse { 
 
     display: none; 
 
    } 
 

 
    .pdf { 
 
     height: 20px; 
 
    } 
 

 
    .arrowup { 
 
     float: left; 
 
     display: inline-block; 
 
     padding-left: 40px; 
 
    } 
 

 
    .arrowdown2 { 
 
     float: left; 
 
     display: inline-block; 
 
     padding-left: 40px; 
 
    } 
 

 
    .arrowdown3 { 
 
     float: left; 
 
     display: inline-block; 
 
     padding-left: 40px; 
 
    } 
 

 
    .arrowdown4 { 
 
     float: left; 
 
     display: inline-block; 
 
     padding-left: 40px; 
 
    } 
 

 
    #border-information { 
 
     border-width: 2px 0px 2px 0px; 
 
     border-color: white; 
 
     border-style: solid; 
 
     margin: 0; 
 
     margin-top: 1px; 
 
     height: 26px; 
 
     width: 100%; 
 
     cursor: pointer; 
 
    } 
 

 
    #border-resources { 
 
     border-width: 2px 0px 2px 0px; 
 
     border-color: white; 
 
     border-style: solid; 
 
     margin: 0; 
 
     margin-top: 1px; 
 
     height: 26px; 
 
     width: 100%; 
 
     cursor: pointer; 
 
    } 
 

 
    #border-comment { 
 
     border-width: 2px 0px 2px 0px; 
 
     border-color: white; 
 
     border-style: solid; 
 
     margin: 0; 
 
     margin-top: 1px; 
 
     height: 26px; 
 
     width: 100%; 
 
     cursor: pointer; 
 
    } 
 

 
    #border-timelapse { 
 
     border-width: 2px 0px 2px 0px; 
 
     border-color: white; 
 
     border-style: solid; 
 
     margin: 0; 
 
     margin-top: 1px; 
 
     height: 26px; 
 
     width: 100%; 
 
     cursor: pointer; 
 
} 
 
    .turn { 
 
     transform: rotate(180deg); 
 
     -o-transform: rotate(180deg); 
 
     -ms-transform: rotate(180deg); 
 
     -moz-transform: rotate(180deg); 
 
     -webkit-transform: rotate(180deg); 
 
    }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> 
 

 
<div class="container"> 
 
    <div class="livestream"> 
 
    <video id="myvideo" class="dacast" height="540px" controls> 
 
    <source src="https://s3-eu-west-1.amazonaws.com/icevideos/140520+Stalbans+Construction+2025/140520.STALBANS.Contruction2025.HIGH.mp4"></source> 
 
    </video> 
 
    </div> 
 
    <a class="overlay"></a> 
 
    <div class="powerpoint"> 
 
    <iframe class="slides" src="https://docs.google.com/presentation/d/1lbTjJ5q4fr1X4rgryWEAmkq-WuWJIoseU7Q1NyqXc44/embed?start=false&loop=false&delayms=3000" frameborder="0" height="540px" allowfullscreen="true" mozallowfullscreen="true" webkitallowfullscreen="true"></iframe> 
 
    </div> 
 
    <div class="sidebar-background"> 
 
    <div id="sidebar"> 
 
     <div class="information"> 
 
     <div id="border-information"> 
 
    <img src="http://cpdonline.tv/ice-events/arrowDown.png" class="arrowup turn" height="26px"><p id="information-text">About this event</p> 
 
    </div> 
 
    <div id="showhide-information" class="panels"> 
 
    <span class="region"> 
 
     <p class="event-float">Event Date - 05/11/2015</p> 
 
     <p>Event Time: 17:30 - 19:30 <br> 
 

 

 
     <p>Speakers: <br> 
 

 
    <span class="indent"><strong> - Cath Schefer</strong> - UK Managing Director, MWH</span><br> 
 
    <span class="indent"><strong> - Professor David Kennedy</strong> - Deputy Director of the Cardiff School of Engineering and professor of Structural Engineering, Cardiff University</span></br> 
 
    <span class="indent"><strong> - Alun Davies</strong> - Business Executive, Alun Griffiths Contractors Ltd</span></br> 
 
    <span class="indent"><strong> - Dawn Turner</strong> - Head of Pension Fund Management, Environment Agency</span> 
 

 
    </p> 
 

 

 
    <span class="description" name="information"> 
 
     <p> 
 
      Presentations will be given on our four strategic themes of; 
 
<br /> 
 
<span class="indent">- Resilience <br /></span> 
 
<span class="indent">- Urbanisation <br /></span> 
 
<span class="indent">- Industry Transformation <br /> </span> 
 
<span class="indent">- Resource Scarcity</span> 
 
      <br /> 
 
      </p> 
 

 
<span class="indent">- London</p> 
 
    </span> 
 
<br /> 
 

 
    </div> 
 
      </div> 
 
    <div> 
 
    <div id="border-resources"> 
 
    <img src="http://cpdonline.tv/ice-events/arrowDown.png" class="arrowdown2" height="26px"><p id="resources">Resources</p> 
 
    </div> 
 
    <div id="showhide-resource"> 
 
    <div class="resource-body" name="resources"> 
 
    <p>Additional resources available to go with this lecture:</p> 
 
    <p class="indent"> - <img class="pdf" src="/new.cpd/ice-events/livestream/img/pdf.png"> This is a pdf.pdf</p> 
 
    </div> 
 
    </div> 
 
    </div> 
 

 
    <div> 
 
    <div id="border-timelapse"> 
 
    <img src="http://cpdonline.tv/ice-events/arrowDown.png" class="arrowdown4" height="26px"><p id="timelapse">Timelapse</p> 
 
    </div> 
 
    <div id="showhide-timelapse"> 
 
    <div class="timelapse-body" name="timelapse"> 
 
    <br> 
 
    <div id="jump">10:00 - This is something</div> 
 
    <br> 
 
    <div id="jump2">20:00 - This is something</div> 
 
    <br> 
 

 
    </div> 
 
    </div> 
 
    </div> 
 

 
    <div id="border-comment"> 
 

 
    <div id="comments"> 
 
    <p class="comment-title"> 
 
    <img src="http://cpdonline.tv/ice-events/arrowDown.png" class="arrowdown3" height="26px"><p id="timelapse">Live Chat</p> 
 
    </p> 
 
    </div> 
 
    </div> 
 
    <div id="showhide-comment"> 
 

 
    <p>ebfgksbgjklsdbghklsg</p> 
 
     </div> 
 
    <br 
 
    </div>

+0

不幸的是,没有工作:( –

+0

@BrendonWells - 哦..我再试一次。谢谢 – vijayP

+0

@BrendonWells - 它可能为你把其他的CSS也放入你的问题 – vijayP

0

同时添加类,试试这个

1.首先删除将要添加类。

2.和之后添加动画类。

$(".arrowup").removeClass("turn"); 
$(".arrowup").addClass("turn"); 
+0

您是否介意解释为什么这会有所帮助? –

0

您的点击功能是否触发?如果不是你的全局showhide变量总是一个,我建议删除全局变量,而是用switch变量作为参数调用changePanel()。调试问题的一个简单方法是在changePanel()函数的开头添加一个console.log(showhide)。

addClass和removeClass的语法是正确的。