jQuery trigger event when click outside the element

前端 未结 11 578
无人共我
无人共我 2020-12-29 02:35
$(document).click(function(evt) {
    var target = evt.currentTarget;
    var inside = $(\".menuWraper\");
    if (target != inside) {
        alert(\"bleep\");
             


        
11条回答
  •  清歌不尽
    2020-12-29 03:10

    I do not think document fires the click event. Try using the body element to capture the click event. Might need to check on that...

提交回复
热议问题