not selector is getting ignored
Hi,
I want to hide my search field when the user clicks ANYWHERE but not on the search field itself and the icon which activates the search field.
I tried it like this:
- $(function() {
- $('.top-searchField').hide();
- $('.icon-close-searchField').hide();
- });
- $(document).ready(function() {
- $('#search-icon').click(function() {
- $('.top-searchField').show('slow');
- $('.icon-top-searchField').hide('slow');
- $('.icon-close-searchField').show('slow');
- });
- $('div').not('.top-searchField, #search-icon').click(function() {
- $('.icon-top-searchField').hide('slow');
- $('.top-searchField').hide('slow');
- });
- });
My icon and my search field look like this:
- <input placeholder="Type something..." class="top-searchField" type="text" />
- <span id="search-icon" class="icon-search icon-white icon-top-searchField"></span>
Every time I click on the icon it shows me the search field but then it's getting hidden again. It is just totally ignoring my not selector!
How do I fix this?