Web devlopers When to use stopPropagation and preventDefault in Javascript?

Поделиться
HTML-код
  • Опубликовано: 4 ноя 2024

Комментарии • 35

  • @gaatutube
    @gaatutube 4 года назад +1

    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.

  • @collinsejindu7922
    @collinsejindu7922 2 года назад +1

    5 years on and I found this very very useful,thanks g

    • @CodingPhase
      @CodingPhase  2 года назад

      it's the foundation of javascript this never going to get old. glad i can help

  • @wilcas5349
    @wilcas5349 4 года назад +2

    Thanks, I understand this finally, after almost 2 years doing software development. You should have written Mozilla documentation.

  • @smithnkereuwem968
    @smithnkereuwem968 3 года назад +1

    Really beautiful explanation here man

  • @alainhonorekubwayo8819
    @alainhonorekubwayo8819 2 года назад

    Very clear explanation, thank you!

  • @raycash409
    @raycash409 7 лет назад +1

    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

  • @kirhab2046
    @kirhab2046 Год назад

    Thanks a million. the best explanation!!!

  • @martipk
    @martipk 2 года назад

    now what is stopImmidiatelPropagation() ?

  • @lbrevilation7083
    @lbrevilation7083 6 лет назад

    why do you put a link if you dont want any action on it ??, why we use exactly PREVENT DEFAULT()?, can explain me ??

  • @hammadarshad1448
    @hammadarshad1448 7 лет назад

    nice, you are a cool developer

  • @Oswee
    @Oswee 6 лет назад

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

  • @jjsmithlago1234
    @jjsmithlago1234 6 лет назад

    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.

  • @srikanthrenatla
    @srikanthrenatla 2 года назад

    Thanks a lot

    • @CodingPhase
      @CodingPhase  2 года назад

      I'm glad this video can still help people

  • @vikasrao4927
    @vikasrao4927 2 года назад

    thanks

  • @codewithmarwan
    @codewithmarwan 3 года назад

    well explained

  • @rayane4975
    @rayane4975 7 лет назад

    How long does it take u to recreate the new instagram layout from scratch ?

  • @VoyceAtlas
    @VoyceAtlas 7 лет назад

    the sign up button on the site does not work fyi

    • @CodingPhase
      @CodingPhase  7 лет назад

      +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

  • @sobeidalagrange7129
    @sobeidalagrange7129 7 лет назад

    Great!!!

  • @MrPDTaylor
    @MrPDTaylor 6 лет назад

    This didn't tell me WHEN to use it. Only how it works.

    • @codewithmarwan
      @codewithmarwan 3 года назад +1

      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

  • @shajahanj2646
    @shajahanj2646 6 лет назад

    i can't understand...

  • @simbobcrafts4843
    @simbobcrafts4843 7 лет назад

    I am not confident I can learn programming at all

  • @yassineaguedid1929
    @yassineaguedid1929 6 лет назад

    love youu

  • @rayane4975
    @rayane4975 7 лет назад

    First

  • @wassollderscheiss33
    @wassollderscheiss33 5 лет назад +1

    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
      @Bandanakm 5 лет назад +1

      what an ignorant comment this is

    • @wilcas5349
      @wilcas5349 4 года назад

      everyone downvote this comment

    • @wassollderscheiss33
      @wassollderscheiss33 4 года назад +1

      @@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!!

  • @JaehoonMe
    @JaehoonMe 4 года назад

    Thanks