HTML
-
asdasdasd
-
asdasdasdasd
-
asdaasdasd
CSS
li .con{display:none;}
JS
$('ul.qna_list').on('click','.tit', function() { var $this = $(this); var $hasCls = $this.hasClass("on"); $this.closest("li").find(".con").stop().slideDown(400); $this.closest("ul").find("li .tit").each(function(){ $(this).removeClass("on"); $(this).closest("li").find(".con").stop().slideUp(400); }).promise().then(function(){ if(!$hasCls){ $this.addClass("on"); $this.closest("li").find(".con").stop().slideDown(400); } }); });
'JavaScript > jQuery' 카테고리의 다른 글
[jQuery] id값으로 다중 모달 띄우기 (0) | 2019.01.21 |
---|---|
[jQuery] 간단한 image 모달 띄우기 (0) | 2018.07.20 |
[jQuery] 체크박스로 활성화,비활성화 제어하기 (0) | 2018.04.18 |
[jQuery] attr("rel")을 사용한 여러개의 탭 만들기 (0) | 2018.04.12 |
[jQuery] Swiper 여러개 사용하기 (0) | 2018.04.11 |