I recently found a very good article of some useful jquery tips and tricks here it is:
http://www.opensourcehunter.com/2010/02/27/26-cool-and-usefull-jquery-tips-tricks-solutions/
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
$("#dialog").dialog();
//Bind to the ui-widget-overlay and watch for when it is clicked
$('.ui-widget-overlay').live("click", function() {
//Close the dialog
$("#dialog").dialog("close");
});
});
</script>
This is how you can check whether the div exists:
if ( $("#message").length ) {
$('#message').text("Hello!");
}