Active Nav Link Indicator with Vanilla Javascript

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 ธ.ค. 2024
  • Apply a class to the navigation link for the current page with a few lines of Javascript.
    Here's the JS: codepen.io/Cod...

ความคิดเห็น • 195

  • @gabrielfono844
    @gabrielfono844 ปีที่แล้ว +13

    I love the way that you explain things
    as software engineer, we all love simplicity.
    thanks for providing such high value to the community

    • @CodinginPublic
      @CodinginPublic  ปีที่แล้ว +2

      That’s very kind. Thanks for saying something!

  • @armandoWebDev
    @armandoWebDev 2 ปีที่แล้ว +15

    The step by step explanation was really great! Thank you

    • @CodinginPublic
      @CodinginPublic  2 ปีที่แล้ว +1

      Great! Thanks for saying something!

  • @siddharththapa4672
    @siddharththapa4672 ปีที่แล้ว +4

    this was the most simplest and on point tutorial on this topic.....much love from INDIA

  • @chooseyourtool
    @chooseyourtool 9 หลายเดือนก่อน

    FINALLY I found your video. I was so much looking for this. But other videos I found were so overcomplicated and missing the point. Thank you, very well done.

  • @princemalongo9303
    @princemalongo9303 8 หลายเดือนก่อน

    Your code is see,simple to understand, and the presentation itself is so sweet.

  • @kllokoq
    @kllokoq 2 ปีที่แล้ว +7

    This is probably the easiest way I've seen of adding an active class. Instead of going and removing the class from the previously selected link, it skips all that non-sense.Lovely!

    • @CodinginPublic
      @CodinginPublic  2 ปีที่แล้ว

      Glad it was a help!

    • @muhammedibrahem5100
      @muhammedibrahem5100 ปีที่แล้ว +1

      He doesn't have to remove the class because the page does refresh on each click, so the class is being removed already once he clicks any of the buttons,
      The solution u are saying is for the same page buttons without any refreshes, at this moment u gotta remove the class then add it to the new clicked button

  • @Pookamensch
    @Pookamensch ปีที่แล้ว

    I saw others solutions, but yours is the most simple and the most well explained of all! Thanks!!!

  • @leonardmbibi8013
    @leonardmbibi8013 2 ปีที่แล้ว +10

    I found out I could use activePage = window.location.href and use strict equality operator to campare it to each "href" with the same results as yours. Your video just introduced me to Browser Object Model. Thanks a lot.

    • @CodinginPublic
      @CodinginPublic  2 ปีที่แล้ว

      Awesome! You're welcome. I also did a follow-up video that should help, too! th-cam.com/video/HpjW9eaFLIg/w-d-xo.html

  • @sarvesh6785
    @sarvesh6785 2 ปีที่แล้ว +2

    Thank you very much, sir! I was trying to find a solution for three hours, but none of them worked. Finally, this worked perfectly.

    • @CodinginPublic
      @CodinginPublic  2 ปีที่แล้ว +1

      Wonderful! Thanks for sharing!

  • @the-beauty-of-creativity2083
    @the-beauty-of-creativity2083 2 ปีที่แล้ว +1

    Thank god I found this video. I lost sometime looking for this solution. Thanks Bro!

    • @CodinginPublic
      @CodinginPublic  2 ปีที่แล้ว

      Awesome! So glad it was a help! Thanks for saying something!

  • @okaniedavis3551
    @okaniedavis3551 2 ปีที่แล้ว +6

    Perfect, exactly what I needed. Thank you!

    • @CodinginPublic
      @CodinginPublic  2 ปีที่แล้ว +2

      You’re welcome!

    • @claudiofernandes6430
      @claudiofernandes6430 ปีที่แล้ว

      Congratulations. This is the best solution that I found in the TH-cam. Thank you very much.

  • @akshayshinde2403
    @akshayshinde2403 3 ปีที่แล้ว +5

    basically we are highlighting that navlink to which it belongs, its that simple. I will use this forever.

  • @pikkuk5693
    @pikkuk5693 2 ปีที่แล้ว +1

    it is so awesome and easy to understand which anyone never told me this video deserve more likes

    • @CodinginPublic
      @CodinginPublic  2 ปีที่แล้ว

      Glad it was a help! Thanks for saying something!

  • @neelamchaubey28
    @neelamchaubey28 2 ปีที่แล้ว +2

    Such an amazing and informative video! Thanks so much. I landed up on this channel through your videos on Shaun's channel. Glad I found it!

    • @CodinginPublic
      @CodinginPublic  2 ปีที่แล้ว

      Thanks so much. Glad you enjoyed it!

  • @darklordpassy5361
    @darklordpassy5361 7 หลายเดือนก่อน

    You explained it so well and simple. Thank you!

    • @CodinginPublic
      @CodinginPublic  7 หลายเดือนก่อน

      Glad it was helpful!

  • @petersonokereke1634
    @petersonokereke1634 2 ปีที่แล้ว

    Thanks so much for this amazing video. JavaScript has been after my life these past few weeks. This solved my problem

    • @CodinginPublic
      @CodinginPublic  2 ปีที่แล้ว +1

      You’re welcome! Glad it was a help! I’ve got an update coming out soon, too!

  • @choanlpoto
    @choanlpoto 2 ปีที่แล้ว +1

    Thanks a lot. I thought having an active link status was super easy like 1 css pseudo elements lol. . I found no good tuto on how to do it. Nothing worked until yours. Awsome Channel subbed. Thx.

    • @CodinginPublic
      @CodinginPublic  2 ปีที่แล้ว +1

      So glad it was a help! Thanks for saying something!

  • @maisha-safari
    @maisha-safari 7 หลายเดือนก่อน

    You are an excellent teacher, thank you.

    • @CodinginPublic
      @CodinginPublic  7 หลายเดือนก่อน

      You're very welcome!

  • @Amalnajah-b2v
    @Amalnajah-b2v ปีที่แล้ว +1

    Thank youuuu I struggled a loot with this so thank you 🎉🎉

  • @yanakochubynska5568
    @yanakochubynska5568 ปีที่แล้ว +1

    This video really helped a lot, thank you!

  • @Ganito55
    @Ganito55 ปีที่แล้ว +2

    Hi!, amazing stuff! Is it easy to stop page refresh? Maybe using ajax/fetch? Many thanks

    • @CodinginPublic
      @CodinginPublic  ปีที่แล้ว

      I'm not sure I understand what you mean?

  • @RJ-gj1zv
    @RJ-gj1zv 2 ปีที่แล้ว +1

    Thanks, man. absolutely brilliant

  • @luciaholubova7504
    @luciaholubova7504 2 ปีที่แล้ว +1

    Hi How do I get the content stay on the page, instead of taking me to new page with using anchor?

    • @CodinginPublic
      @CodinginPublic  2 ปีที่แล้ว

      Anchor links can take you to any element on the page with an ID. It takes two steps:
      1. Create a page element with an ID. Like this…
      Hi, I’m a link!
      2. Point the href of an anchor tag to that ID. like this…
      Click to jump
      (Note the #)
      Whenever you click the link, it’ll jump to that ID on the page.

  • @brucewernick6542
    @brucewernick6542 9 หลายเดือนก่อน

    You put a forward slash in front of the anchor links. So, when running in a browser, this makes it try to find the file in the root directory. I removed this forward slash and it works in browser and the local web server.

  • @cesarpacheco9155
    @cesarpacheco9155 2 ปีที่แล้ว +1

    Profesor muchas gracias por este video me sirvio de mucho saludos desde Colombia

  • @RohitSharma-wq4ok
    @RohitSharma-wq4ok ปีที่แล้ว +2

    Sir on home page it apply to all links active class and on console it show active 5 link in only on home page

    • @CodinginPublic
      @CodinginPublic  ปีที่แล้ว +1

      On some sites that's the case. Did an update that fixes that an a few other issues :) th-cam.com/video/HpjW9eaFLIg/w-d-xo.html

  • @rajkiranchaudhary8769
    @rajkiranchaudhary8769 2 ปีที่แล้ว +2

    Thanks a lot for this amazing content.

  • @moneyfr
    @moneyfr 2 ปีที่แล้ว +1

    Do you know how make dynamic navbar (all forder page show into navebare) for each li maybe?

    • @CodinginPublic
      @CodinginPublic  2 ปีที่แล้ว

      I’m not sure I understand? Here is a video I did on navbars recently though. Hopefully that helps.
      th-cam.com/video/63sxOYm9GwY/w-d-xo.html

  • @mxrrae
    @mxrrae 2 ปีที่แล้ว +1

    hi, My problem is when in the url doesn't have "index.html", It active for all the link. what should is do?

    • @CodinginPublic
      @CodinginPublic  2 ปีที่แล้ว +1

      Yes, I’ve done a more recent tutorial on the same topic to address this problem. Hope it helps!
      th-cam.com/video/HpjW9eaFLIg/w-d-xo.html

    • @mxrrae
      @mxrrae 2 ปีที่แล้ว

      Thanks for that 😘

  • @slv9780
    @slv9780 20 วันที่ผ่านมา +1

    Bro u got a new subscriber

  • @ingridsantos1143
    @ingridsantos1143 2 ปีที่แล้ว +1

    Thanks so much. This tutorial was really helpful and well explained.

    • @CodinginPublic
      @CodinginPublic  2 ปีที่แล้ว

      Wonderful! Thanks for saying something!

  • @efieugenia
    @efieugenia 2 ปีที่แล้ว +1

    What a wonderful tutorial

  • @makidelavega3079
    @makidelavega3079 2 ปีที่แล้ว +1

    Thanks for this video ,it helped me a lot.

    • @CodinginPublic
      @CodinginPublic  2 ปีที่แล้ว

      Wonderful! Thanks for saying something!

  • @connorbyram3649
    @connorbyram3649 ปีที่แล้ว +3

    This is a wonderful solution. I was having an issues where ALL of my nav links had the active class added to them- because I am utilizing a directory. To skirt this I came up with this: By directly/strictly comparing the window href and the link href, there is only one possible match.
    document.querySelectorAll('.nav-links a').forEach(link => {
    if(link.href === window.location.href) {
    link.classList.add('active');
    }
    });

    • @CodinginPublic
      @CodinginPublic  ปีที่แล้ว

      Great! Yeah, I updated this video here to work the way it SHOULD have worked. :) th-cam.com/video/HpjW9eaFLIg/w-d-xo.html

    • @ylitandi
      @ylitandi ปีที่แล้ว

      Thank you very much ! So the code is : const activePage = window.location.pathname;
      const navLinks = document.querySelectorAll('.nav-links a').forEach(link => {
      if(link.href === window.location.href){
      link.classList.add('active');
      console.log(link);
      }
      }); ??? 🙂

    • @connorbyram3649
      @connorbyram3649 ปีที่แล้ว

      @@ylitandi I will have to look back at my code. But that should work. Have you demoed it? Also, there's no need for that console.log(link).

  • @behold_a_son
    @behold_a_son 2 ปีที่แล้ว +1

    Is there a need to synchronize the desktop navbar active states to mobile navbar active states if both the styles are different? Meaning If I click the mobile nav link. The same link in the desktop nav should be active and vice versa. I spent a lot of time and accomplished this in a practice problem but I'm worried that it was not worth the effort.

    • @CodinginPublic
      @CodinginPublic  2 ปีที่แล้ว +1

      Thanks for the comment. Hmm…assuming you have the desktop/mobile nav bar set to display:none whenever it's not showing, it shouldn't matter. If they're both rendered and you set them both to active, that would cause some accessibility issues, I believe. FWIW, I usually only have one nav that I just style differently depending on viewport width (example: th-cam.com/video/63sxOYm9GwY/w-d-xo.html), so I usually don't run into your question.

    • @behold_a_son
      @behold_a_son 2 ปีที่แล้ว

      @@CodinginPublic Thank you, that's insightful!

  • @ankurdohare2261
    @ankurdohare2261 2 ปีที่แล้ว +1

    what if first page is "/" instead of "/index.html" ? we cannot use link.hred.include in that case

    • @CodinginPublic
      @CodinginPublic  2 ปีที่แล้ว +1

      I did this follow up video with that in mind: th-cam.com/video/HpjW9eaFLIg/w-d-xo.html
      Hope that helps!

    • @ankurdohare2261
      @ankurdohare2261 2 ปีที่แล้ว

      @@CodinginPublic you are god😍, Thank you. I resolved one of the story at my firm . Thanks a lot🥳🥳🥳

    • @ankurdohare2261
      @ankurdohare2261 2 ปีที่แล้ว

      @@CodinginPublic Thanks for replying that fast 😁

  • @alphamx13
    @alphamx13 ปีที่แล้ว

    Great! Just one question... how can you also add the active class to the menu section if you scroll down or up the page ? Thank U!

    • @CodinginPublic
      @CodinginPublic  ปีที่แล้ว +1

      I’ve done a tutorial like this a long time ago, but not finding it right now. Sorry!

  • @hexd7439
    @hexd7439 3 ปีที่แล้ว +1

    Thanks a lot! This tutorial helped me.

    • @CodinginPublic
      @CodinginPublic  3 ปีที่แล้ว

      Awesome! Thanks for saying something!

  • @cheesychains
    @cheesychains 2 ปีที่แล้ว +1

    This saved me, thank you so much!

  • @RuiOut8
    @RuiOut8 2 ปีที่แล้ว +3

    Thank you! This is really helpful! Does this concept work for one page websites where the Nav links to IDs within the same HTML file?

    • @CodinginPublic
      @CodinginPublic  2 ปีที่แล้ว +2

      You’re welcome! For IDs on a one-page site it’s even easier! You can use the :target pseudo selector to apply styles to the nav links using only CSS!

    • @RuiOut8
      @RuiOut8 2 ปีที่แล้ว

      @@CodinginPublic awesome! Thank you very much!

  • @sebastianszydlowski5834
    @sebastianszydlowski5834 2 ปีที่แล้ว +1

    This function adds active class to all links when websote is visited for the forst time. How can I remove this class?

    • @CodinginPublic
      @CodinginPublic  2 ปีที่แล้ว

      Hmm. It shouldn’t. Happy to view your code and give you a solution. Feel free to DM on Twitter or share a public link.

    • @CodinginPublic
      @CodinginPublic  2 ปีที่แล้ว

      Hey! I saw you commented, but TH-cam deleted it before I could see it. 🙄 feel free to try again or DM me on Twitter at @cpenned.

    • @CodinginPublic
      @CodinginPublic  2 ปีที่แล้ว

      Okay, so it deleted it, but the preview showed me enough! Ha. The problem is your window.location.pathname will include the directory (/wordpress/) and since your homepage includes that pathname and all four links include that section in their pathname, they're all highlighted.
      My initial thought is that you should just clip out the "/wordpress/" from the pathname, which you can do with the substring method (assuming all your menu items will always be in that directory, wordpress). The substring takes a number as an argument and basically slices off those indexes from your string.
      So in all, change …
      const activePage = window.location.pathname;
      to …
      const activePage = window.location.pathname.substring(10);
      ---
      Let me know if that doesn't make sense or doesn't solve your problem.

    • @sebastianszydlowski5834
      @sebastianszydlowski5834 2 ปีที่แล้ว

      @@CodinginPublic Thank you for the reply. Did not work. I noticed it for the first time when the site was on localhost. I will let you know if it is working after migration.

    • @CodinginPublic
      @CodinginPublic  2 ปีที่แล้ว

      @@sebastianszydlowski5834 Ah-sorry you're still having trouble with it. For what it’s worth, I used the solution I mentioned in your live site (just changed the JS file) and it worked properly in my tests, but it all depends on the folder structure. Happy to help more if it would be a help.

  • @andrewlawton2487
    @andrewlawton2487 2 ปีที่แล้ว +1

    Thank you very much for the video. I implemented your code accordingly and experiencing one issue I'd greatly appreciate your assistance with. When I click the nav home link all the links become active and I'm not sure why? Looking at the console.log it shows all path names not just the home page index.html. Thank you in advance for your help.

    • @CodinginPublic
      @CodinginPublic  2 ปีที่แล้ว

      Glad it was a help! Hmm…I’m guessing you’re in a directory? Like…www.website/temp/
      If that’s the case, all links in your nav links will include the directory (“temp” in this example).
      Go to your home page and console.log(window.location.pathname)
      Assuming that’s the problem it will include the directory and you can remove it by using the substring method.
      If that’s not clear or doesn’t work, feel free to drop a link to a GitHub or something or DM on Twitter at cpenned.

    • @andrewlawton2487
      @andrewlawton2487 2 ปีที่แล้ว

      @@CodinginPublic Thank you for your quick reply Chris. I will let you know if your suggestion works. Thanks again!

  • @pbt4820
    @pbt4820 10 หลายเดือนก่อน

    thank you for the vid. I am trying to have the viewed page underlined instead of highlight with black blocks. is that possible with this method?

    • @CodinginPublic
      @CodinginPublic  10 หลายเดือนก่อน

      Sure! Just switch up the CSS. I'd make it have a transparent underline (border-bottom) when not selected and then just the color you want when it is selected.

  • @nigelpallatt
    @nigelpallatt 3 ปีที่แล้ว +1

    BRILLIANT THANK YOU!

    • @CodinginPublic
      @CodinginPublic  3 ปีที่แล้ว +1

      Awesome! Glad you liked it!

    • @nigelpallatt
      @nigelpallatt 3 ปีที่แล้ว

      @@CodinginPublic Sort of had a typo on the first try, but it works lovely now, I'll be using this from now on all my sites, Thank you again and great work!

    • @CodinginPublic
      @CodinginPublic  3 ปีที่แล้ว

      👀

  • @okaniedavis3551
    @okaniedavis3551 2 ปีที่แล้ว

    Is there a way to do this for sub links in a side panel inside a parent link, like a tree, To make the parent link remain open displaying child/sub links? Is there a video that can help me?

    • @CodinginPublic
      @CodinginPublic  2 ปีที่แล้ว +1

      There is a way to do this; not sure about a video? I haven't done one. Sorry! :)

    • @okaniedavis3551
      @okaniedavis3551 2 ปีที่แล้ว

      @@CodinginPublic After all, this video was also enough to achieve what I wanted with my parent and child links. Thank you 👌

  • @sal-so2rw
    @sal-so2rw ปีที่แล้ว +2

    What's happening I can't see things clearly

    • @CodinginPublic
      @CodinginPublic  ปีที่แล้ว

      It's highlighting the active page link in the nav bar. Is that what you're asking?

  • @sydneysolomon5500
    @sydneysolomon5500 ปีที่แล้ว

    Hi, I am looking for a tutorial, when you click Home button or any other it takes you the information that is the particular button. Do u have such a tutorial?

    • @CodinginPublic
      @CodinginPublic  ปีที่แล้ว

      Do you mean anchor links?

    • @sydneysolomon5500
      @sydneysolomon5500 ปีที่แล้ว

      @@CodinginPublic Yes...example if you click on the HOME button it should take you whatever is the text about NOME. Same for all the other buttons.

    • @CodinginPublic
      @CodinginPublic  ปีที่แล้ว

      @@sydneysolomon5500 Been a long time since I did this, but I think this is along the lines of what you want? th-cam.com/video/PolXp-MWJcs/w-d-xo.html

  • @chriswesleypierre1440
    @chriswesleypierre1440 ปีที่แล้ว

    precise, quick, useful

  • @juanalmonte1642
    @juanalmonte1642 2 ปีที่แล้ว +1

    Good and easy to understand

  • @Rahul-ur6xz
    @Rahul-ur6xz 2 ปีที่แล้ว +1

    What Editor Do You Use ?

    • @CodinginPublic
      @CodinginPublic  2 ปีที่แล้ว

      I think I was using Nova in this video, but I use VSCode now.

  • @adrian20065
    @adrian20065 3 ปีที่แล้ว +1

    Thanks a lot for this tutorial! I recently came across you channel and subscribed. How can you keep the parent active is it has children? Thanks again!

    • @CodinginPublic
      @CodinginPublic  3 ปีที่แล้ว

      Thanks so much! Just to make sure I understand, are you wanting to keep the parent active if it has a submenu?

    • @adrian20065
      @adrian20065 3 ปีที่แล้ว

      @@CodinginPublic Yes, I want to keep the parent active if it has a submenu. Thanks for the quick reply.

    • @CodinginPublic
      @CodinginPublic  3 ปีที่แล้ว

      Just saw today that TH-cam blocked your reply and never notified me. Sorry! You still need help?

    • @adrian20065
      @adrian20065 3 ปีที่แล้ว

      @@CodinginPublic Yes, I still like to know how to keep the parent menu item active when the child menu item is selected. Thank you.

  • @kamaboko1
    @kamaboko1 ปีที่แล้ว

    Superb explanation.

  • @nazmussakib9346
    @nazmussakib9346 ปีที่แล้ว

    Hey brother, I need some help... Please reply to my comment... I applied this JavaScript on my blogger blog... Everything's perfect but when I'm on the home page the active class is added to all of the links instead of adding to only the home page link... Why is this happening?

    • @CodinginPublic
      @CodinginPublic  ปีที่แล้ว

      Fixed in this video :)
      th-cam.com/video/HpjW9eaFLIg/w-d-xo.html

  • @ak-yo6pf
    @ak-yo6pf ปีที่แล้ว +1

    you are a g thanks for that!

  • @mohamed_younes77
    @mohamed_younes77 ปีที่แล้ว

    thx man very simlpe and clear

  • @dadwalkanishka9210
    @dadwalkanishka9210 ปีที่แล้ว

    thanks for the code it was helpful for me

    • @CodinginPublic
      @CodinginPublic  ปีที่แล้ว

      So glad! Thanks for taking the time to say something!

  • @yofi2614
    @yofi2614 2 ปีที่แล้ว

    Great tutorial, so clear and plesant to here, thank!
    One quick question,
    let say you click the home button and it gets the active class,
    But what remove this class in next rounds?
    Logically it should have left this class on every button that had been clicked so eventually if you click all the buttons all of them will be black

    • @CodinginPublic
      @CodinginPublic  2 ปีที่แล้ว

      Glad it was a help! Because you’re applying the class using client-side JavaScript, the class will be removed each time you change to a different page. Once you arrive on the next page, you can apply the class again for the current page you’re on at that time. Does that make sense?
      I’ve actually updated my process for applying active links here: th-cam.com/video/HpjW9eaFLIg/w-d-xo.html

    • @yofi2614
      @yofi2614 2 ปีที่แล้ว

      @@CodinginPublic totally makes sense cause i haven't learnt client side js yet, but i will look up at the link you gave, so much thankful for the quick respond! Subscribed!

    • @CodinginPublic
      @CodinginPublic  2 ปีที่แล้ว

      You’re welcome! Client-side JavaScript means JavaScript that the site visitor’s browser runs (so like the JavaScript we wrote in this video). In other words, it’s only applied once the page loads. Hopefully that helps some. Thanks for the sub!

    • @yofi2614
      @yofi2614 2 ปีที่แล้ว

      @@CodinginPublic thanks!

  • @MaksymMinenko
    @MaksymMinenko 2 ปีที่แล้ว

    The codepen has only the JS file...

    • @CodinginPublic
      @CodinginPublic  2 ปีที่แล้ว

      Well, because every site is so different and the focus was on implementing the JS for any page. Let me know if you get stuck. Happy to help!

  • @Thailand-Wanderer
    @Thailand-Wanderer 3 ปีที่แล้ว +1

    Very helpful!

    • @CodinginPublic
      @CodinginPublic  3 ปีที่แล้ว

      Good to hear! Thanks for saying something!

  • @Steve-rx4sw
    @Steve-rx4sw 2 ปีที่แล้ว +1

    good work bro. thanks

    • @CodinginPublic
      @CodinginPublic  2 ปีที่แล้ว

      glad it was a help! Thanks for saying something!

  • @sokcheahong1468
    @sokcheahong1468 2 ปีที่แล้ว +1

    really helpful

    • @CodinginPublic
      @CodinginPublic  2 ปีที่แล้ว

      Thanks for saying something. Glad it was a help!

  • @asidermakriver
    @asidermakriver 3 ปีที่แล้ว +1

    Thank you!

    • @CodinginPublic
      @CodinginPublic  3 ปีที่แล้ว

      You’re welcome! Thanks for saying something!

  • @ggff8782
    @ggff8782 2 ปีที่แล้ว +1

    Not hover before clicking

    • @CodinginPublic
      @CodinginPublic  2 ปีที่แล้ว

      not sure I understand? Did I style it wrong? I can’t remember-this has been a while :)

  • @MuhammadAdnan2.0
    @MuhammadAdnan2.0 2 ปีที่แล้ว

    Bro what about these slugs contact%20Us ?

    • @CodinginPublic
      @CodinginPublic  2 ปีที่แล้ว +1

      Did a follow-up video for these types of situations :) th-cam.com/video/HpjW9eaFLIg/w-d-xo.html

    • @MuhammadAdnan2.0
      @MuhammadAdnan2.0 2 ปีที่แล้ว

      @@CodinginPublic great thnx

  • @salmajahan5834
    @salmajahan5834 7 หลายเดือนก่อน

    Thank you so much, super like

    • @CodinginPublic
      @CodinginPublic  7 หลายเดือนก่อน

      Glad you enjoyed it!

  • @codingislife6387
    @codingislife6387 2 ปีที่แล้ว

    thanks Sir Jee. It Very Help Full Thanks .

  • @ricardomartinhodacruz
    @ricardomartinhodacruz ปีที่แล้ว

    thank you for this tuto. I actually had to use window.location.href instead of pathname since Im using different slugs to the same pathname between product categorys in php.

    • @CodinginPublic
      @CodinginPublic  ปีที่แล้ว

      Yes! I ended up updating the video later to something much better here :) th-cam.com/video/HpjW9eaFLIg/w-d-xo.html

  • @sbf.2189
    @sbf.2189 ปีที่แล้ว

    Thank you so much man

  • @lordilhamgod4417
    @lordilhamgod4417 2 ปีที่แล้ว

    Works well!! DANKEEE

  • @ankitmakwana3141
    @ankitmakwana3141 3 ปีที่แล้ว +1

    awsm great!!

  • @wtfmomentninenine
    @wtfmomentninenine ปีที่แล้ว

    thank you, sir

  • @Dontmesswithmeplease
    @Dontmesswithmeplease 2 ปีที่แล้ว +1

    YOu are king, :) . Alexander the great

  • @surbhipaliwal3576
    @surbhipaliwal3576 2 ปีที่แล้ว +1

    Sir please give all files

  • @itszeynepk
    @itszeynepk 2 ปีที่แล้ว

    thank you so much

    • @CodinginPublic
      @CodinginPublic  2 ปีที่แล้ว

      You’re welcome! Thanks for saying something!

  • @Dontmesswithmeplease
    @Dontmesswithmeplease 2 ปีที่แล้ว +1

    Super

  • @SharoAliDevelpor
    @SharoAliDevelpor ปีที่แล้ว +1

    Wow i need it but plz provide the source code

  • @beautifularabicnasheed2323
    @beautifularabicnasheed2323 2 ปีที่แล้ว

    code plase

  • @tmm476
    @tmm476 5 หลายเดือนก่อน

    u da mann

    • @CodinginPublic
      @CodinginPublic  4 หลายเดือนก่อน +1

      glad you found it helpful!

  • @usef439
    @usef439 2 ปีที่แล้ว

    Thanks!

    • @CodinginPublic
      @CodinginPublic  2 ปีที่แล้ว

      You’re welcome! Thanks for saying something!

  • @AlThePal78
    @AlThePal78 2 ปีที่แล้ว

    i wish you had the css for this too on your code pen but still n awesome vid

    • @CodinginPublic
      @CodinginPublic  2 ปีที่แล้ว +1

      Yeah, sorry 😞. This was before I was saving all code from my videos I think

    • @AlThePal78
      @AlThePal78 2 ปีที่แล้ว

      @@CodinginPublic that is okay I am stealing this and making my own video lol I will add a secondary class called link so I can add an underline and change the backgrouind color etc.. thanks so much :)

  • @jivara5523
    @jivara5523 11 หลายเดือนก่อน

    ty very much

  • @suresranathunga
    @suresranathunga ปีที่แล้ว

    💙💙

  • @MrFreak0r
    @MrFreak0r ปีที่แล้ว

    Easier way with just 2 lines of CSS:
    .current-menu-item a {
    color: #FFFFFF !important;
    background: #2889AE !important;
    }
    So much useless stuff with all the html and javascript. I don't want to hack into the pentagn, just make the active menu item highlighted....

    • @CodinginPublic
      @CodinginPublic  ปีที่แล้ว

      This is such a long time ago I’m sure I’d do it differently than however I did it in this video. Just be careful about those !important flags. They can get you into trouble :)
      I’d also consider using the aria-current=“page” attribute instead of a class to make this more accessible.

  • @footballcorner6
    @footballcorner6 ปีที่แล้ว

    Thank you so much

  • @omniadarweesh2013
    @omniadarweesh2013 16 วันที่ผ่านมา

    Thank you so much