我们经常会出现点击空白处关闭弹出框或触发事件
<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之外的地方时会触发事件,这里可以写业务和逻辑

相关文章:

  • 2022-12-23
  • 2021-11-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
猜你喜欢
  • 2022-12-23
  • 2021-11-04
  • 2021-11-30
  • 2022-12-23
相关资源
相似解决方案