DEV Community

Discussion on: The Web I Want

Collapse
 
jamesdhasselman profile image
James D. Hasselman

As a back end developer who is trying to learn front end development this caught my eye. I'm curious how you would accomplish things like drop-down menus that "mobile first" sites have these days. At this point in my journey I'm not aware of any way to take action on a click other than JavaScript (form submit and links aside of course).

Collapse
 
codesenseinc profile image
Steve McGinnis

The HTML Select Element is all that is needed. No JS required.

Collapse
 
quii profile image
Chris James • Edited

Hey!

A lot of drop-down menus do suck a fair bit on mobile, so tread with caution. If you do need JavaScript how will users without JavaScript use your site? Maybe a drop-down menu isn't the way.

Let's imagine you're set on having a dropdown menu anyway!

I don't know a way how to do it without JS either (that's not to say there isn't a way) so in your case I'd write a little Javascript.

Just to be clear, a lot of people are misinterpreting me (or miscommunication on my part) in saying never use javascript. Feel free to use it, if it's really needed and think about the consequences of it.

Overall my main objection is to large amounts of javascript ruining perfectly good content for lots of users when it wasn't really needed in the first place.

Collapse
 
briankephart profile image
Brian Kephart

You can do dropdowns with CSS transformations. Wish I had a good example, but the app I'm doing now is behind a login.

Thread Thread
 
quii profile image
Chris James

Sounds like an excellent idea for a post here :)

Thread Thread
 
briankephart profile image
Brian Kephart

I'm thinking about it, but I'm not yet convinced I wouldn't just be repeating something posted elsewhere. Looking around though, it looks like I combined approaches that I found in other posts, so it might be worthwhile.