Método jQuery event.stopPropagation()

❮ Métodos de eventos jQuery

Exemplo

Pare o evento de clique de borbulhar para os elementos pai:

$("span").click(function(event){
  event.stopPropagation();
  alert("The span element was clicked.");
});
$("p").click(function(event){
  alert("The p element was clicked.");
});
$("div").click(function(){
  alert("The div element was clicked.");
});

Definição e uso

O método event.stopPropagation() interrompe o borbulhar de um evento para os elementos pai, impedindo que qualquer manipulador de evento pai seja executado.

Dica: Use o método event.isPropagationStopped() para verificar se esse método foi chamado para o evento.


Sintaxe

event.stopPropagation()

Parameter Description
event Required. The event parameter comes from the event binding function

❮ Métodos de eventos jQuery