<div class="aa" style="width: 200px;height: 200px;background-color: red;"></div>
js代码
$(document).mouseup(function(e) { var _con = $('.aa'); // 设置目标区域 if (!_con.is(e.target) && _con.has(e.target).length === 0) { alert("4545"); } });
当我们点击此div之外的地方时会触发事件,这里可以写业务和逻辑