当使用jquery单击时,我正在尝试关闭可折叠菜单的内容。下面我附上了小提琴以供参考。
<div id="advent">
<i id="arrow" class="fa fa-plus-circle" style="margin-left:40px"></i>
Advent
<div id="expand" style="display:none">Content</div>
</div>
<script>
$('#advent').click(function () {
$("#arrow", this).toggleClass("fa-minus-circle");
$('#expand').show();
if($this.hasClass()){
$('#expand').slideUp();
}
});
</script>发布于 2018-01-09 02:22:23
只需使用toggle或slideToggle
$('#advent').click(function () {
$("#arrow", this).toggleClass("fa-minus-circle");
$('#expand').slideToggle();
});https://stackoverflow.com/questions/48155900
复制相似问题