Use jQuery to hide a DIV when the user clicks outside of it

I am using this code:

$('body').click(function() {
   $('.form_wrapper').hide();
});

$('.form_wrapper').click(function(event){
   event.stopPropagation();
});

And this HTML:

<div class="form_wrapper">
   <a class="agree" href="https://stackoverflow.com/questions/1403615/javascript:;">I Agree</a>
   <a class="disagree" href="https://stackoverflow.com/questions/1403615/javascript:;">Disagree</a>
</div>

The problem is that I have links inside the div and when they no longer work when clicked.

37 s
37

Leave a Comment