외부영역 클릭시 팝업 닫기

dev·2022년 8월 23일
0

JS

목록 보기
3/4

외부 영역 클릭시 팝업 닫기 기능

function bindClickEvent() {
    $('.alert-close').click(function (e) { //닫기버튼으로 닫기
        $this = $(e.target);
        $this.closest('.terms__alert').hide();
    });
    $(document).mouseup(function (e) { //외부영역 클릭시 팝업 닫기
        let $layerPopup = $('.terms__alert');
        if($layerPopup.has(e.target).length === 0) {
            $layerPopup.hide();
        }
    });
}
profile
hello world!

0개의 댓글