I'm new to jQuery and I did my best to throw together a function that on click opens a dialog message, and on click again closes it. What I want is to be able to click outside the dialog (anywhere on the screen) to close that dialog. How can I accomplish this in the setup I wrote? Also, is the code I currently have done correctly, or could I do it another, easier way?
EDIT (10/17/12):
I've updated the jQuery below to include part of Ryan Wheale's code, and this is the current status:
-"clickoutside" works for the currently open span
-Trying to open another span closes the current span and subsequently the new span
jQuery: http://www.eclipsisna.com/?ena=services
$(".service_outline a, .service_title a, .service_price a").click(function() {
$(this).closest("a").children("span").fadeToggle("fast", function() {
$("span").not(this).fadeOut("fast");
});
$(this).one("clickoutside", function () {
$("span").fadeOut("fast");
});
});
HTML:
<td class="service_outline">
<h11><a>Opti-<br><h12>Coat</h12><span><font color="#ffcc00">•</font> Application of permanent, nano ceramic clear resin coating (replaces "Wax"/"Sealant")<br><font color="#ffcc00">•</font> Extended durability for 2+ years<br><font color="#ffcc00">•</font> $250<p><center><img src="images/opti-coat.png"></center></span></a></h11>
</td>