title: Why document click listener triggers immediately?
body: <p>I want to bind a click function to the document when open some menu via click.
  The problem is that when trigger the first event 'click on the menu', the function attached to the document has been triggered by the same event and close the menu. How to solve that issue. My code is something like that: </p>
  
  <pre><code>$('#openMenu').bind('click touchend', function(e){
      e.preventDefault();
      $('.openMobMenu').removeClass('openMobMenu');//Close All elements
      var _this=$('#headMenu')
      _this.addClass('openMobMenu');
  
      $(document).bind('click touchend',{elem:_this},hideElementMob);
  });
  
  // bind click event listner to the document
  function hideElementMob(e){
  
      var th=e.data.elem;//Get the open element
      var target=$(e.target);//Get the clicked target
  
          //Check the target and close the element if need
      if(target.parents('.openMobMenu').length==0) { 
          th.removeClass('openMobMenu');//close the element if need
          //Unbind listner after closing the element
          $(document).unbind('click touchend');
      } 
  } 
  </code></pre>
  
  <p>Thank you in advance!</p>