Now I am closing the alert box when I clicked on the 'x' but I want
to close the alertbox when I click outside of
it.
Please see my code here : href="http://jsfiddle.net/Ur5Xn/" rel="nofollow">http://jsfiddle.net/Ur5Xn/
How to close alertbox clicking outside of
it?
The
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();
});
});
class="normal">Answer
try this
code
$(document).ready(function(){
function showAlertBox(){
$("#alert").css("display","inherit");
$("#content").addClass("back");
}
function
removeAlertBox(){
$("#alert").css("display","none");
$("#content").removeClass("back");
}
$("#alertClose").click(function(e){
e.stopPropagation();
removeAlertBox();
});
$("#alertShow").click(function(e){
e.stopPropagation();
showAlertBox();
});
$(document).click(function(e){
removeAlertBox();
});
});
No comments:
Post a Comment