点击元素内部不隐藏,点击元素外部元素隐藏
$(document).on("click", function (evt) { var oEvent = evt || event; var elem = oEvent.target || oEvent.srcElement; while (elem) { //循环判断至跟节点,防止点击的是div子元素 if (elem.id && elem.id=='moreStockBox') { return; } elem = elem.parentNode; } $scope.chooseStockShow = false; });