Close modal dialog box when clicked outside

23 Jun , 2011  

I was searching for a way to close my modal dialog box when clicked outside of the dialog and i found a very good article by Ryan Jeffords at: http://www.ryanjeffords.com/blog/entry/closing-a-jquery-ui-dialog-when-the-dialog-loses-focus

Thanx Ryan

<script type="text/javascript">
   //Wait for the document to load
   $(document).ready(function() {
      //Create the dialog and open it
      //Bind to the ui-widget-overlay and watch for when it is clicked
      $('.ui-widget-overlay').live("click", function() {
         //Close the dialog


Check whether the div exists [Jquery]

21 Jun , 2011  

This is how you can check whether the div exists:

if ( $("#message").length ) {