H
H
HamSter2016-07-14 15:43:54
JavaScript
HamSter, 2016-07-14 15:43:54

Why click doesn't fire, but mouseup does?

Here is an example .
Interested in line 66

// Скрыть тултип при клике вне кнопки
         $(document).on('click', function(e){
        var container = $('.tooltip');
          if (container.has(e.target).length === 0) {
              $(".tooltip").remove();
          }			
});

The task is to hide the tooltip when clicking anywhere in the document.
Why doesn't it work click?
It's not the first time I've encountered this.
I replace it clickand mouseupeverything works.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
napa3um, 2016-07-14
@HamSter007

Because some element has a click event handler that does event.stopPropagation(), preventing the event from bubbling up the parent chain to the document element. More details: https://learn.javascript.ru/event-bubbling .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question