안녕하세요. 이벤트 수업을 듣고 응용을 해보고있는데
버튼 외 영역을 클릭하면 'show'클래스를 지우고 드롭다운을 닫고 싶어
콘솔로그로 테스트를 해봣는데
현재 코드로는 오히려 버튼을 클릭하니 콘솔로그가 나오고 있습니다
if( e.target !== $('.site_drop').children('.btn')){
console.log('드롭다운영역을 닫습니다')
}
이 부분이 문제인것 같은데 모르겠어서 질문드립니다
----------
//HTML
//JS
$('.site_drop').children('.btn').click(function(e){
$(this).next().toggleClass('show');
$('.site_drop').children('.btn').not($(this)).next().removeClass('show');
if( e.target !== $('.site_drop').children('.btn')){
console.log('드롭다운영역을 닫습니다')
}
})