jQuery event.stopPropagation() Yöntemi
Örnek
Click olayının ana öğelere köpürmesini durdurun:
$("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.");
});
Tanım ve Kullanım
event.stopPropagation() yöntemi, bir olayın üst öğelere köpürmesini durdurarak herhangi bir üst öğe olay işleyicisinin yürütülmesini engeller.
İpucu: Bu yöntemin olay için çağrılıp çağrılmadığını kontrol etmek için event.isPropagationStopped() yöntemini kullanın.
Sözdizimi
event.stopPropagation()
Parameter | Description |
---|---|
event | Required. The event parameter comes from the event binding function |