Drop down menu | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson

Drop down menu

So I spent a looong time to get a dropdown menu with pure JavaScript but it wasn't working. So I used jquery. Pls can someone create a dropdown with the html code below using pure JavaScript? It won't take a lot of time for you guys. Thanks https://code.sololearn.com/W8rYlTdk0mA9/?ref=app

11th Aug 2018, 12:56 PM
Emeruche Ikenna Cole
Emeruche Ikenna Cole - avatar
1 Answer
+ 5
window.onload = function() { document.getElementById("btn").addEventListener("click", function() { clicked() }, true) } function clicked() { var menu = document.getElementById("menu") if(menu.classList.contains("menuToggle")) { menu.classList.remove("menuToggle"); return; } menu.classList.add("menuToggle"); }
11th Aug 2018, 1:17 PM
Toni Isotalo
Toni Isotalo - avatar