How To Make A Dropdown Menu From Scratch | HTML, CSS, Javascript

Поделиться
HTML-код
  • Опубликовано: 19 мар 2022
  • Learn how to build a custom dropdown menu from scratch, using HTML, CSS and Javascript. A simple guide to making a more interesting dropdown UI element with subtle animations, hover effects, and much more...
    Get The Source Code From All Of My Videos:
    www.buymeacoffee.com/webcode/...
    Don't hesitate to ask for help if you face any trouble re-creating a project from any of my videos. I will gladly help :)
    All of my project are made from scratch by yours truly. I don't take anyone's code as my own, but I do often see my code being copied and pasted into other channels for their tutorials, so of you see an exact copy of a project on another tutorial, just know that the one on my channel is the original one.
    Extra Links:
    -----------------
    Follow me on Instagram:
    / quickcodingtuts
    My Products:
    www.buymeacoffee.com/webcode/...
    Support Me To Keep Creating And Improving My Content:
    paypal.me/quickcodingtuts?loc...
    www.buymeacoffee.com/webcode/
    Tags:
    -----------------
    #dropdown
    #javascript
    #menu
    javascript dropdown menu
    custom select menu
    html css javascript dropdown from scratch
  • ХоббиХобби

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

  • @quickcodingtuts
    @quickcodingtuts  6 месяцев назад

    Take a look at a more polished version of this dropdown here:
    ruclips.net/video/TOozMj7RLOQ/видео.html

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

    tried and works fine. looks easy to expand for many more menus.. liked it much.

  • @anthonymelohorstmann1238
    @anthonymelohorstmann1238 10 месяцев назад +7

    Wonderfully edited, along with splendid code; congrats!

  • @cold_
    @cold_ Год назад +8

    Fantastic video! Your dropdown is working excellently!

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

    Wow, thanks for the vid - exactly what i was looking for!

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

    Fantastic info, thank you !

  • @_Fantom_.
    @_Fantom_. 6 месяцев назад +1

    Thank you bro! Very beautiful!

  • @jenso413
    @jenso413 2 года назад +7

    Awesome video! I love the format, and the menu looks awesome too

    • @quickcodingtuts
      @quickcodingtuts  2 года назад +3

      Thanks for watching!

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

      @@quickcodingtuts I need your help, Please!!! I have a language dropdown, but in each language there is a img flag of that country, I use your dropdown, but I don't know how to make the flag in the select change??

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

      You can set the flag img source in the select to the source of the clicked option.

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

      @@quickcodingtuts



      Eng / $






      Ukr / ₴



      Tr / ₺



      Eng / $

  • @user-fi2up8gz2q
    @user-fi2up8gz2q 19 дней назад +1

    not only beautiful and polished video you made but it was also direct and right to the point thank you so much

  • @MuhibAfridiWeapons
    @MuhibAfridiWeapons 8 месяцев назад +2

    Thank you so much dude.

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

    thank you so much bro, really helped me and your explanation of the code is 100% clean

  • @oscarcollerde4375
    @oscarcollerde4375 11 месяцев назад +1

    Its wonderfull, thanks..

  • @JonThomasslaps
    @JonThomasslaps 2 месяца назад

    Hello im having issues, console log shows syntax issue on everything that does not end in endcurly brace. Ex: dropdowns.forEach(dropdown => {
    another ex is option.addEventListener('click',() =>

  • @PatriciaSL
    @PatriciaSL 7 месяцев назад +1

    Thank you so much! This was so easy to follow.

  • @jabeztadesse
    @jabeztadesse 2 месяца назад +1

    I tried it! And it works flawlessly!

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

    Amazing Video, I had a class contest and came first, love this so much. ❤

  • @satoupendragon7329
    @satoupendragon7329 Год назад +3

    Could you help me, when typing transition: background 0.3s; the word background appears in red (typed background-color for now). Also when clicking the drop down arrow, it rotates fine but no dropdown options are showing. Any help with this would be great.

  • @mithunkinarullathil643
    @mithunkinarullathil643 10 месяцев назад

    Heyo, thank you for the amazing tutorial. A small change in js, once you select an option from the drop down the .select-clicked style is persisting. You can solve by toggling it again.
    // Remove active class from all options
    options.forEach(option => {
    option.classList.remove('active');
    select.classList.toggle('select-clicked');
    });

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

    thank you so much for this!!

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

    i liked this projet is verry simple and fast!

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

    My code is working on code pen but not on any other compiler what could be the issue please help

  • @pejcaa_
    @pejcaa_ 6 месяцев назад +1

    Cant open dropdown, also have little problem in code... transtion: background 0.3s; the background is all red

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

    What parameters would i change to change the location of the button?

  • @markjensen7489
    @markjensen7489 6 месяцев назад

    I get an error about the document not being defined in the Java-script "Error: document is not defined".

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

    Thnk u so much. I just have a little problem, I have 2 dropdowns in different positions, everything works right except for the caret. First dropdown works right, it does the 180 deg transform correctly, but the caret for the second doesn't, I mean, it does rotate, but it ends in a different position when rotated. Is there anyway to change that?

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

      I would try adding more dropdowns to see what happens then. One working while the other one doesn't is pretty weird though.

  •  Год назад +1

    According to your project:
    I choose Figma from one menu and Twitter from the other. I assign a choice to variables. But querySelector ('. selected') overrides the second selection. How to solve it?

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

      Have you assigned the querySelector to the dropdown element? That allows you to use more dropdowns that work independently from each other.

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

    is this html code semantic? is it going to have accessibility issues?

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

    BEST CHANNEL

  • @sarahkay2656
    @sarahkay2656 11 месяцев назад

    Love the music

  • @codingwithobidjon1193
    @codingwithobidjon1193 Год назад +20

    Good bro. but it's not working😐😐

    • @Wanderer2035
      @Wanderer2035 Год назад +5

      Double check spelling, one spelling mistake or misplaced curly brace can break the whole code

    • @justfisher2920
      @justfisher2920 3 месяца назад

      Check your code more carefully, likely you've made mistake

  • @luispedroordonez9134
    @luispedroordonez9134 9 месяцев назад

    thank you so much for help me

  • @samithegayfrog6213
    @samithegayfrog6213 Год назад +7

    My code isn’t working and I’m not sure why haha

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

    red>background< red what can i install or what do I do

  • @snime7772
    @snime7772 2 месяца назад

    do you use a plugin to actively update the page while you're coding? if so what is it?

    • @quickcodingtuts
      @quickcodingtuts  2 месяца назад

      Just something i put together with HTML, CSS and JavaScript

  • @jayceetan3704
    @jayceetan3704 11 месяцев назад

    Hi i am encountering some problem, i have followed exactly on all the codes from html to CSS to Javascripts shown in the video, i have added the before the too, but i am not sure why the dropdown doest work. the hovering seems fine. i think its my javascript not working which idk why

    • @quickcodingtuts
      @quickcodingtuts  11 месяцев назад

      Do you have any errors in the console, after clicking the dropdown button?

    • @fit-pull-kit
      @fit-pull-kit 9 месяцев назад +1

      Because your javascript is not getting called and it is because you are not calling javascript function on event call from html. In this video he missed this part.

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

    Como puedo hacer que funcione en un servidor json, en un archivo ejs

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

    how can i click outside and it close?

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

    Excellent video! How can I do to close the menu by clicking on any part of the screen? I’m not being able to solve it

    • @quickcodingtuts
      @quickcodingtuts  Год назад +4

      I could release a new video with that and many more features I overlooked in this one. Would that help?

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

    For anyone running into the "options.forEach is not a function" error, make sure that you use querySelectorAll when declaring the options variable, not querySelector. Its easy to miss this small detail in the video. Hope this helps!

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

    thx! also how do you make the options actually do something?

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

      You simply put the code that you want to run in the options event listener.

  • @jabeztadesse
    @jabeztadesse 2 месяца назад +1

    I have a question, what is the source for the Caret? Is it an SVG or a PNG or what? (Love your Video!)

    • @quickcodingtuts
      @quickcodingtuts  2 месяца назад

      Thank you. The caret is made with CSS entirely. No images whatsoever.

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

    hi, I have a problem. Actually did everything even added pics and it worked very well in normal html,css,js file however when it comes to the react.js it does not work, if you ask me iw say that it is problem of js bcz every single think works except js part when it is clicked it doesnot open anything. JS code is between function and return. It would be very nice if i have a lil help. Thanks in advance :)

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

      I have this exact project built with React. You can find it on my channel.

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

      @@quickcodingtuts can you pls share the link to the comment?

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

      @@quickcodingtuts dude thanks actually i did find it and coded it. but i have to put images near to every li element but i dont know how to do it can you help me?

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

      You can insert them like any other image, with the img tag.

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

      @@quickcodingtuts but how?const dropdownList = options.map((option,i) =>
      ,
      {option}
      )
      like this?

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

    Is dropdown.querySelector a function? I thought only document.querySelector and .querySelectorAll exists

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

      Yes. This selects only the elements inside the dropdown. I combine this with a loop to have multiple dropdowns on the page work independently from each other

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

      You can use the querySelector function on any element just like with the document

  • @Ali-ho1ji
    @Ali-ho1ji Год назад

    hello, where should add the js? head body or inside the div?

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

      Add it just before the closing body tag. I recommend learning the basics of HTML before recreating projects like this one.

  • @DeepakYadav-bm1ks
    @DeepakYadav-bm1ks Месяц назад

    From where i can get code of this video?

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

    I only have the first dropdown works. 😪 The console shows error: "Uncaught TypeError: options.forEach is not a function". Any advice?

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

      please help ^^ I have the same error as well

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

      When you created the options variable, did you use querySelectorAll?

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

      const options = dropdown.querySelectorAll('.menu li');
      Make sure its querySelectorAll and not just querySelector

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

      @@quickcodingtuts yes, I followed your code strictly

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

      @@billng1527thanks!

  • @cyprienrubio8058
    @cyprienrubio8058 9 месяцев назад

    love it

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

    great video😍 what text editor do you use?

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

      I use VS code. But what you see in the video is an app I built myself.

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

    will it work for me i have 3000 elements in list to add to dropdown

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

      Yes, but you should also set overflow of hidden and a fixed height to the menu. There is also the problem of searching for an option amongst 3000 choices. You would need to add a search option to filter the list for a better user interface.

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

    how do you get the value from the selected option?

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

      We do that with the "innerText" property, which will get the inner text of the option we click on.

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

    This is nice but: how can i add that js file to my html so my html understands to read my js file too

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

      Add a script tag above the closing body tag and paste your JS in there. I recommend learning the basics of HTML, CSS and JS before trying out a project like this

  • @priyanshiagarwal1424
    @priyanshiagarwal1424 4 месяца назад

    I am not able to get all the drop down

  • @narinnarin5244
    @narinnarin5244 11 месяцев назад

    hi..please can you make web mapping tutorials ... or give me resources.

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

    I followed the step, but the dropdown doesnt showup when I click it.... what will be the issue?

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

      Can't know for sure. Can be a lot of things. Any errors in the console?

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

      @@quickcodingtuts where should I put the log for debugging? thx

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

      Is all the source code mentioned in the video? I have watched 3 times to ensure there was no typo.

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

      @@thomasluk4319 Of course. The final result is made from the code in the video

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

      @@quickcodingtuts Then I really dont know why... I will try this for a complete new project and double check it again

  • @umarmughal3297
    @umarmughal3297 11 месяцев назад

    hi my dropdown list arrow not show please tell me how to do it

    • @quickcodingtuts
      @quickcodingtuts  11 месяцев назад +1

      Carefully follow the CSS code for the caret class

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

    quelqu’un pourrait copié coller sont script java cars moi je n’y arrive pas

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

    First dropdown works fine but 2nd is not working?
    how to fix that ?

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

      Have you followed the query selection at the top of the js file? We do it a little differently here to make multiple dropdowns work. If you made a mistake, it will probably be there.

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

    Does this works with image-icons?

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

    man i would have $$ brought access, but i clicked on the link and could not find this video's source code, so im on to the next channel

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

      The source code for this video is uploaded and available ever since the video came out. You can find it in the 'UI elements' category

  • @s1nk428
    @s1nk428 11 месяцев назад

    It doesn't work, I did 1 in 1 as in the video, but nothing happened, the dropdown does not appear

    • @quickcodingtuts
      @quickcodingtuts  11 месяцев назад

      Are you familiar with the basics of these languages. Do you know how to connect CSS and Javascript files to your HTML and setup a starting HTML template?

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

    is it possible to add a database form mysql workbench to this dropdown menu and use it as a filter?

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

      Don't see a reason why it wouldn't. You can just switch the static data with whatever else you need.

  • @user-zf9yk3rk6o
    @user-zf9yk3rk6o 10 месяцев назад

    i am getting errors...

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

    I subscribed but can't find the source code for this one. can you please send me a link?

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

      Hello. I have sent the link to your email. You can find this in the UI elements category on Buy Me A Coffee. And you can also search for any other project you need. I usually name them the same as I name the video.

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

      @@quickcodingtuts can you send it to me also??

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

      Here is the link to all source code:
      www.buymeacoffee.com/webcode/posts
      But this is a small project. I'm sure there is just a small mistake you made in the code. Are there any errors or anything happening on the page that could give me a clue on how to help?

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

    Doesn’t work. Skip the source code

  • @user-wt2mk3ex1w
    @user-wt2mk3ex1w 4 месяца назад

    Nice dropdown but not working.Could you please help me to figure it out .

    • @quickcodingtuts
      @quickcodingtuts  4 месяца назад

      Sure. What kind of problem are you facing?

    • @user-wt2mk3ex1w
      @user-wt2mk3ex1w 4 месяца назад

      Thank you so much .I have resolved the issue.

    • @user-wt2mk3ex1w
      @user-wt2mk3ex1w 4 месяца назад

      But one thing is that after refreshing the page or if I navigate to other page and then come back to that page, set option is also refreshed . I don't want that in my project .
      Thanks

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

      You can use Local storage for that.

    • @user-wt2mk3ex1w
      @user-wt2mk3ex1w 3 месяца назад

      Ok

  • @user-gw4xs1gw5l
    @user-gw4xs1gw5l Год назад +1

    👍👍

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

    How to add scroll bar inside

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

      Add a fixed height for the menu and add overflow: scroll;

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

      @@quickcodingtuts ❤️ thank you it's working

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

    how to calling javascript ?

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

      in your html file

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

    Let the github, please brather ?

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

    song: ruclips.net/video/Z1Qi_B2C9gE/видео.html

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

    hii i need help

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

      What seems to be the issue?

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

      @@quickcodingtuts its all good but i want to be able to filter them out accordingly to the menu. could you give me some help?

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

      @@daniyamary5862 I have a JS filter tutorial. Its one of my newer videos. You can use it to apply the same methods here.

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

      @@quickcodingtuts okie thank youu!!

  • @TheNormMan
    @TheNormMan 4 месяца назад

    Is it really that complicated? If yes i hate html and css

    • @quickcodingtuts
      @quickcodingtuts  4 месяца назад

      We are building the whole thing from scratch, so that we can customize it however we want. These things are always difficult in the beginning when ou are still learning how it's done, but with enough practice and examples it becomes easier. Always improve with small steps so you don't get overwhelmed.

  • @buntyagarwal7717
    @buntyagarwal7717 6 месяцев назад

    Its not working

    • @quickcodingtuts
      @quickcodingtuts  6 месяцев назад +1

      No way for me to help you with just " its not working"

    • @jabeztadesse
      @jabeztadesse 2 месяца назад

      Exactly@@quickcodingtuts

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

    Eldropdown no funciona y se nota que con todo el proposito lo hizo para derivar a los usuarios a otro medio de contacto. La verdad que videos así no sirven

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

      Hello. I assure you that the code in the video works. You can also see that it works for other people in the comments. Surely there is something misstyped in your code that would make it not work. I'm always here to help if I can manage my time. All the best.

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

    Aint working bro, checked multiple times

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

      Have you checked the console for errors. Linked booth the stylesheet and script into your HTML?

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

      @@quickcodingtuts yes ivevcgecked multiple times, it says that the there is error where it says "addEventListener" even tho there aint nothin wrong

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

      Denial isn't going to get you anywhere. If the console has an error, then there is a mistake in the code. Trust me, you want to use the console to your advantage as soon as possible, and get used to solving errors.

  • @tabeampersand6851
    @tabeampersand6851 Месяц назад

    😇