How do I write 'if not clicked' or 'if clicked outside element', using Jquery?
<p>I'm kind of stuck on a problem of how to stop my menu from executing the fadeOut() function. When I click the main links on my menu to open the submenu it just fades out. Here is how the code looks at the moment:</p>

<pre><code>    $('a.main-menu-item').click(function(){

    if($('.rtmenu:visible')){

        $('.rtmenu').click(function(e) { e.stopPropagation(); });

        $(document).click(function() {
            $('.rtmenu').fadeOut(200);
        });
    }
})
</code></pre>

<p>Can anyone tell me how I can write 'if not clicked a.main-menu-item' where it says 'document'?</p>

<p>Much Appreciated</p>

<hr>

<p><strong>SOLUTION FOUND!</strong></p>

<pre><code>$('.rtmenu').click(function(e) { e.stopPropagation(); });
$('.rtmenu').mouseout(function(){ 
     $(document).one('click',function() { $('.rtmenu').fadeOut(200); }); 
 })
</code></pre>
