0
Can anyone share any javascript code for responsive drop-down menu ?
please share only javascript if you have no jquery
3 Respostas
+ 1
You could try something like this to open and close it, but it won't be animated.
// give the button and menu elements IDs
var menu = document.getElementById("menu");
function toggleMenu(){
if (menu.style.display == "none"){
menu.style.display = "block";
}
else{
menu.style.display = "none";
}
}
var button = document.getElementById("button");
button.addEventListener("click", toggleMenu);
The CSS is the tricky part, though. You want it positioned nicely. Try using absolute positioning and putting the menu in a div with the open/close button.
This is only a very basic menu, sorry.
0
thanks