现在,我点击'x'时关闭了警告框,但当我单击其外部时,我想关闭警报框。如何关闭在它外面的div点击
请在这里看到我的代码:http://jsfiddle.net/Ur5Xn/
如何关闭alertbox点击之外呢?
jQuery的:
$(document).ready(function(){
function showAlertBox(){
$("#alert").css("display","inherit");
$("#content").addClass("back");
}
function removeAlertBox(){
$("#alert").css("display","none");
$("#content").removeClass("back");
}
$("#alertClose").click(function(){
removeAlertBox();
});
$("#alertShow").click(function(){
showAlertBox();
});
});
或http://stackoverflow.com/questions/152975/how-to-detect-a-click-outside-an-element – epascarello
只是为了清楚这一点,这不是一个警告框。这只是一个div。 –