tags:

views:

192

answers:

3

Hello

<div id="servisesmenu">
      <span class="services" title="Сервисы">Сервисы</span>
</div>
<div id="services_menu" class="hiddenmenu">
    <div class="framemenu">
        <div class="itemmenu"><a href="/flights_booking/" class="u" title="Покупка авиабилетов онлайн">Покупка авиабилетов онлайн</a></div>         
        <div class="itemmenu"><a href="/hotels/" class="u" title="Бронирование гостиниц онлайн">Бронирование гостиниц онлайн</a></div>          
        <div class="itemmenu"><a href="/sea_cruises_search/" class="u" title="Поиск круизов">Поиск круизов</a></div>            
        <div class="itemmenu"><a href="/flights_panel/" class="u" title="Табло аэропортов">Табло аэропортов</a></div>           
    </div>
</div>

$('.services').click(function() {
        $('#services_menu').attr('class') == 'hiddenmenu'  ?   $('#services_menu').attr('class', 'visiblemenu')    :   $('#services_menu').attr('class', 'hiddenmenu');
    });

It's okay.

But...How can I make by clicking on any place on the page, this field disappeared (class a hiddenmenu)

Sorry for bad english. Thank you!

A: 

Are you looking for this:

$(document).click(function(){
  $('.hiddenmenu').hide();
});
Sarfraz
In this case, the first oncklik does not work
Isis
+1  A: 

I've just recently done something similar to this.

$('body').click(
  function(){
    // hide whatever
  }
);

Then for whatever you're hiding.

$('.services').click(
  function(e){
    // code
    e.stopPropagation(); // this stops the click event on the body from propagating.
  }
);
Jeremy
Everything works, but if you click on servises, then a body, then again on the services, it does not open anything
Isis
You'll have to make sure your click events are not conflicting. That is if you're body click event is hiding something needed in order for your services click event to fire.
Jeremy
If I click on any place on the page, then never doesn't open $('#services_menu')
Isis
Oh, sorry.$('#services_menu').attr('class', 'hiddenmenu'); it's work, but hide() don't work
Isis
Are you still having trouble? If you are, post your code in something like jsbin.com, it'll make it easier for me to help.
Jeremy
A: 

@Isis What about this?

  $(document).live('click', function(){
      $('.hiddenmenu').hide();
    });
c0mrade
doesn't work too
Isis