But... how to deal in case if i have onclick action on parent (red box) element and i need to access exactly parents event.target, but user click on link area (he can do it). Think of some fancy tab, button or some card with icons, texts etc. event.target will return the element user was clicked and it not always will be parent (where onclick actually was attached).
Does anybody else ever get "TypeError: Cannot read property 'preventDefault' of undefined". i've NEVER gotten preventDefault to work. It always does this reaguardless of what I'm doing with it.
event.prevent default can be used for many reasons and one might related to user auth as you might not want user to get redirected to another page unless he was authorized to. event.stopPropgation can be quite useful for animations as well as for example you might want to have animation for the parent click event and another different animation for the button click event and what would happen is clicking the child element will trigger both his and his parent/s animations which is not good, you can avoid that by using stop propagation so only the clicked child animation is triggered and his parents animations will not be triggered. I am not sure if this was a clear explanation, this was just me improvising haha
When I heard you talking I immediately wanted to give you a downvote. But the content is actually good. Understandable and not too long also. Well done. You just happen to have the speaking habitus of someone living on the street ;-)
@@Bandanakm What? Me? I am so tolerant! I can accept homeless underclass people giving talks about programming languages. I'm great, I'm generous. Maybe some day that guy may even get a job in an actual company! Imagine that!!
Very clear. Thanks. Had read about these 2 things multiple times over the years but could never really wrap my head around them. Now I can.
Glad it was helpful!
5 years on and I found this very very useful,thanks g
it's the foundation of javascript this never going to get old. glad i can help
Thanks, I understand this finally, after almost 2 years doing software development. You should have written Mozilla documentation.
Really beautiful explanation here man
Very clear explanation, thank you!
Damn I feel dumb as hell cuz I ain't even got to this in JavaScript yet lol. I'll save it to my bookmark for when I do get to it. Appreciate it my g
Thanks a million. the best explanation!!!
Glad it was helpful!
now what is stopImmidiatelPropagation() ?
why do you put a link if you dont want any action on it ??, why we use exactly PREVENT DEFAULT()?, can explain me ??
nice, you are a cool developer
But... how to deal in case if i have onclick action on parent (red box) element and i need to access exactly parents event.target, but user click on link area (he can do it). Think of some fancy tab, button or some card with icons, texts etc. event.target will return the element user was clicked and it not always will be parent (where onclick actually was attached).
Does anybody else ever get "TypeError: Cannot read property 'preventDefault' of undefined". i've NEVER gotten preventDefault to work. It always does this reaguardless of what I'm doing with it.
Thanks a lot
I'm glad this video can still help people
thanks
well explained
How long does it take u to recreate the new instagram layout from scratch ?
the sign up button on the site does not work fyi
+VOYCE ATLAS yes every day I add something new. Sorry about that it's just a way for people to see the progress of the site
Great!!!
This didn't tell me WHEN to use it. Only how it works.
event.prevent default can be used for many reasons and one might related to user auth as you might not want user to get redirected to another page unless he was authorized to. event.stopPropgation can be quite useful for animations as well as for example you might want to have animation for the parent click event and another different animation for the button click event and what would happen is clicking the child element will trigger both his and his parent/s animations which is not good, you can avoid that by using stop propagation so only the clicked child animation is triggered and his parents animations will not be triggered. I am not sure if this was a clear explanation, this was just me improvising haha
i can't understand...
I am not confident I can learn programming at all
love youu
First
When I heard you talking I immediately wanted to give you a downvote. But the content is actually good. Understandable and not too long also. Well done. You just happen to have the speaking habitus of someone living on the street ;-)
what an ignorant comment this is
everyone downvote this comment
@@Bandanakm What? Me? I am so tolerant! I can accept homeless underclass people giving talks about programming languages. I'm great, I'm generous. Maybe some day that guy may even get a job in an actual company! Imagine that!!
Thanks
No problem