I need help with this code in Javascript as I toggle the drop-down menu it won't show up.
CSS
@media screen and (orientation: portrait) and (min-width: 360px) {
.navbardropdown{
display: none;
text-align: center;
background-color: darkblue;
line-height: 60px;
list-style: none;
}
.navbardropdown a{
color: white;
text-decoration: none;
}
.dropmenu {
display: block;
}
}
Javascript
function showDDmenu () {
navbardropdown.classList.toggle("dropmenu");
}
CodePudding user response:
Unless it's defined somewhere else, navbardropdown
is undefined
Try this:
function showDDmenu () {
const navbardropdown = document.querySelector('.navbardropdown')
navbardropdown.classList.toggle("dropmenu");
}
CodePudding user response:
Try using
$('.navbardropdown').toogle(function() {
$('.dropmenu').css('display', 'block')
})