+ 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.
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