Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
19
rated 0 times [  20] [ 1]  / answers: 1 / hits: 65608  / 14 Years ago, thu, december 23, 2010, 12:00:00

How do I stop custom event bubbling in jQuery?



For example I have this code:





$('.myclass').bind('amodaldestroy', function(){
....does something.....
})


How do I only allow this to be triggered once on the first element it finds when bubbling? Can I just add return false?



$('.myclass').bind('amodaldestroy', function(){
....does something.....
return false;
})

More From » jquery

 Answers
31

According to jQuery's documentation:



$('myclass').bind('amodaldestroy'), function(event) {
....does something....
event.stopPropagation();
});

[#94504] Wednesday, December 22, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
karivictoriab

Total Points: 530
Total Questions: 90
Total Answers: 95

Location: Honduras
Member since Sun, Dec 26, 2021
2 Years ago
;