NullVoxPopuli
NullVoxPopuli

Reputation: 65183

How does one close an overlay by clicking outside of the overlay?

I have a jquery drop down that activates and deactivates when you click the header for the drop down

$j('#category_header').click(function() {
    $j('#category_dropdown').slideToggle("fast");
    return false;
});

but I want it to also close when I click anywhere on the page that isnt the drop down. How do I go about doing that?

Upvotes: 1

Views: 7684

Answers (2)

NullVoxPopuli
NullVoxPopuli

Reputation: 65183

Got it

$j(function() {
    $j('body').click(function() {
        $j('#category_dropdown').slideUp("fast");
        return false;
    });

});

Upvotes: 0

SBUJOLD
SBUJOLD

Reputation: 1473

Look at the answer for this question: How do I detect a click outside an element?

Upvotes: 2

Related Questions