Sunday, 24 November 2013

Close popup div when clicked outside


Below is the script that solves the mentioned problem. I have not personally tested the code. You might want to try it out yourself.



$(function(){
   $("#btnFieldWorkers").click(function(e){       
       e.stopPropagation();
       $("#div_fieldWorkers").show();
       $("body").click(function(e){
           if(e.target.id != "div_fieldWorkers")
           {
               $("#div_fieldWorkers").hide();
               $("body").unbind("click");
           }
       });
   });

});
 
 
Reference: 

http://stackoverflow.com/questions/19092433/close-popup-div-when-clicked-outside 

No comments:

Post a Comment

We are moving

We are moving this blog to our new blog site: https://ciysys.com/blog/nodejs.htm