Close Hide DIV when Clicking outside in jQuery

Last Reply 5 months ago By chetan

Posted 5 months ago

I am working on alpha.dubaiexporters.com.

http://alpha.dubaiexporters.com/aboutus.aspx


There is go button and after clicking on go button,search panel appears where i can perform search keyword and category.

The issue is that after clicking on go button,search panel appears but if the user does not want to perform any search,he clicks outside anywhere but that search panel
does not go.

How to achieve that?

You are viewing reply posted by: chetan 5 months ago.
Posted 5 months ago

Hi sir...This Worked for me:

 

        $(document).click(function (e) {
            if (e.target != $(".sb-icon-search")[0] && (e.target.parentElement.parentElement != $(".header-form-container")[0])) {
                $(".header-search-body")[0].style.display = 'none';
            }
        });

        $(".header_search").click(function (e) {
            $(".header-search-body")[0].style.display = 'block';
        });