jquery tooltip - click to open and click to close
<p>I have a jquery popup working that shows on click. I need to make it hide again when the same selector is clicked. But at the moment it just flashes and reloads. I have set it up so it closes if you click anywhere that is not the selector but this is not really what I need.</p>

<p>Here is my code which works perfectly I just need to know how to make it hide when it is clicked again.</p>

<p>Basically what I think I need to know is how to keep track what selector has been clicked (there are multiple items that can be clicked on the same page all with the same class) so I can say if that is clicked again close it??</p>

<pre><code>$(document).ready(function(){
        $("#tooltip").hide();
        $("a.highScoreTooltip").click(function(){                                             
            var game = $(this).attr('title');
            var offset = $(this).offset();
            var top = offset.top - 43;
            var left = offset.left + 155;
            $.ajax({
                type: "POST",       
                data: 'game=' + game,   
                url: "&lt;?=$server_url?&gt;leaderboard_popup.php", 
                cache: false,
                success: function (html) { 
                    $("#tooltip").show();
                    $("#tooltip").html(html);
                    $("#tooltip")
                        .css("top",top + "px")
                        .css("left",left + "px")
                        .fadeIn("fast");
                }      
            }); 
        });
        jQuery(document).delegate(':not(#tooltip)', 'click', function(){
            $('#tooltip').hide();
        });
    });
</code></pre>
