+ 2

What is different between 'preventDefault' , 'stopPropagation', and 'off' method event manipulation jQuery?

When we have a event, and we need to supress it (or cancel the action of it), what is the appropriate method should be use? I wonder what is the different between 'preventDefault', 'stopPropagation' and 'off' event handler.

29th Jun 2017, 8:14 AM
Fendi Septiawan
Fendi Septiawan - avatar
1 Réponse
+ 5
off method is like YourHTMLElement.removeEventListener() no need to interest Now focus on 'prevent' and 'stop' Let's say that I have <button> and <div> which is parent of <button> stop: if you added click event on button and use stop the event will prevent only that content (doesn't affect to parent) prevent: As usual.still affect to parent Doesn't different much.... https://goo.gl/oNqUFW
29th Jun 2017, 9:39 AM
Yanothai Chaitawat
Yanothai Chaitawat - avatar