Add and Remove Active Class on Click

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

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

  • @huna7a
    @huna7a Год назад +6

    God, dude, you saved my ass. Im a beginner in javascript and I headbang over this for 3 straight days.

    • @ash_of_hope519
      @ash_of_hope519 5 месяцев назад

      What the hell same man :o !

    • @bastian-z9w
      @bastian-z9w 11 дней назад

      yes i wrote a much more difficult solution last time now i see i can write it much more efficient...i almost thought there must be a simpler solution for this situation cause every website has this feature.

  • @ixtiyaragayev2406
    @ixtiyaragayev2406 Год назад +2

    Thank you so much, No other videos I've watched couldn't solve the problem this clean.

  • @Yunraii
    @Yunraii Год назад +1

    Thank you very much for this. I was complicated myself trying to add something like this on my website but you made it so clear to understand it and the solution itself was way easier than other codes I found on the internet. Much apreciated ❤

  • @Ayushsingh-in1si
    @Ayushsingh-in1si Год назад +1

    This tutorial was very helpful, it will be great if you create playlist that includes these kind of videos. I checked on your channel there wasn’t any of them.
    I have done the basics in js like classes, objects, etc. and was struggling with finding these type of tutorials that actually matters. Sadly everyone has made the tutorials on js till basic language and their content is too length, unstructured.
    Please create playlists on your channel it will help new learners allot. 🙏🙏

  • @sadique_x_
    @sadique_x_ Год назад +2

    you really saved me about an hour man
    much appreciated

  • @PatrycjaOosthuizenCode
    @PatrycjaOosthuizenCode 9 месяцев назад +1

    Thank you for this explanation after few days of trying different methods finally I found your channel with perfect solution 🙌

  • @Pharmtechie
    @Pharmtechie 4 месяца назад +1

    Bro thanks a lot
    I have spent more than 5hrs with this.

  • @sebastianlozano7707
    @sebastianlozano7707 Год назад +1

    I spent 2 hours trying to do it man!

  • @anthonyjibueze8413
    @anthonyjibueze8413 9 месяцев назад +1

    Thank you for this. Used it on a client website after watching this video.

  • @photoinshot1355
    @photoinshot1355 Год назад +1

    Very clear and precise tutorial and well explained, thanks. I have two nav bars ,top and bottom but this only works either top or bottom depending on which one was clicked anyone with any ideas on how to fix? Pointers welcome

  • @kalidomar2531
    @kalidomar2531 Год назад +1

    Thank you very much, that was easy and on point.

  • @MuhammadAli-kj9jc
    @MuhammadAli-kj9jc 4 месяца назад

    I am subscribed your channel for this video. it helped to solve my problem

  • @sotorius_27
    @sotorius_27 Год назад +1

    you're the best dude

  • @piano_izi
    @piano_izi Год назад +1

    God bless you!

  • @MadDoxXx_01
    @MadDoxXx_01 Год назад +2

    thanks for tutorial but what when we scroll to different section of page? it doesn't change according to that.

  • @herbiejames5637
    @herbiejames5637 23 дня назад

    does line 5 make all "active" elements in the document lose "active", or just the navLinkEls?

  • @SG_Media31
    @SG_Media31 Год назад +1

    Thanks alot 😇😇

  • @kurisu26
    @kurisu26 Год назад +1

    Thanks. That single question mark saved me hours. lol

  • @bastian-z9w
    @bastian-z9w 11 дней назад

    Thanks for the video. Does it work if i have links like and so on? because on reload it will be removed?!

  • @saravafaei7708
    @saravafaei7708 Год назад +1

    Awesome ❤

  • @mdabdulahallnomantuhin3621
    @mdabdulahallnomantuhin3621 5 месяцев назад +1

    Thank you very much brother😊😊😊

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

    Awesome this helps me in project thanks

  • @JulioCesar-hh9wq
    @JulioCesar-hh9wq 10 месяцев назад +1

    Thank you

  • @ПетнаестСедамнаест

    And how to deselect everything (all buttons) when clicked on an empty space?!!

  • @Entertainment.Tube0
    @Entertainment.Tube0 11 месяцев назад +1

    awesome...

  • @Aliena92
    @Aliena92 10 месяцев назад +1

    Thank you a lot! How can we do this with tailwind?

  • @krishnavamsi1126
    @krishnavamsi1126 4 месяца назад +1

    thanks guru

  • @محمدحمدي-و7ح7ح
    @محمدحمدي-و7ح7ح 8 месяцев назад +1

    thanks a lot

  • @jacoblue5245
    @jacoblue5245 8 месяцев назад

    Why use add and remove? Doesn’t “toggle” do the same?

  • @Filmy_Wallah
    @Filmy_Wallah 10 месяцев назад +1

    After wasting 4hours finally now i do it

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

    How to make it so upon page refresh my first div to become or stay the current active page 😢 its accordion menu related thing i want upon refresh the first div to become the active div if its not already the active div and I want if its the current active div before the refresh to stay the active div after the refresh

  • @Dstoic
    @Dstoic 6 месяцев назад +2

    I was putting the dot thats why my code was not working..lol

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

    I am a little confused here could anybody help me understand the following. A const navLinksEls was created but within the function, navLinksEls is being referred to as navLinksEl without the s at the end how does that work?

    • @mestayno
      @mestayno Год назад +1

      In my understanding he could've named whatever that element. It just means that for each of those elements individually. He could've named it something like element, el, or even rabbit

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

      As Atilla said, you can name it anything but he used navLinksEl to refer to the buttons.