Skip to content Skip to sidebar Skip to footer

Javascript Onclick Function Doesnt Execute (error Log - Not Defined)

I can't get this for the life of me... I've tried to make a mobile friendly nav that gets hidden if the screen res is less than 600px and a button appears that toggles the menu opa

Solution 1:

Seems like you have chosen improper load type at jsfiddle. Instead of load type - on load use no wrap - in body.

Credits to @Pointy.

enter image description here

functionmenudrop() {
    document.getElementById("menu-icon").classList.toggle("change");

    document.getElementById("navlist").classList.toggle("show");
  }
@media screen and (max-width: 600px) {
  .navlist {
    background-color: white;
    border: 1px solid black;
    right: 15%;
    opacity: 0;
    z-index: 99;
  }
  .navlistli {
    border: none;
    font-size: 25px;
    float: none;
  }
  #menu-icon {
    display: inline-block;
  }
}

.navlist {
  width: auto;
  margin: 0px;
  padding: 0px;
  margin-right: 5%;
  -webkit-padding-start: 0px;
  -webkit-margin-before: 0px;
  -webkit-margin-after: 0px;
  font-family: "Roboto", sans-serif;
  display: inline-block;
  position: relative;
}

.navlistli {
  float: left;
  font-size: 14px;
  padding: 10px15px;
  border-right: 1px solid black;
  list-style: none;
  text-decoration: none;
  position: relative;
}

.navlista {
  color: black;
  text-decoration: none;
  transition: color 0.3s;
  /* vendorless fallback */
  -o-transition: color 0.3s;
  /* opera */
  -ms-transition: color 0.3s;
  /* IE 10 */
  -moz-transition: color 0.3s;
  /* Firefox */
  -webkit-transition: color 0.3s;
  /*safari and chrome */position: relative;
}

.navlista:hover {
  color: #00bff3;
  position: relative;
}

.menu-icon-black {
  display: inline-block;
  cursor: pointer;
}

.menu-icon-bar1,
.menu-icon-bar2,
.menu-icon-bar3 {
  width: 45px;
  height: 5px;
  background-color: #333;
  margin: 6px0;
  transition: 0.4s;
}


/* Rotate first bar */.change.menu-icon-bar1 {
  -webkit-transform: rotate(-45deg) translate(-9px, 7px);
  transform: rotate(-45deg) translate(-9px, 7px);
}


/* Fade out the second bar */.change.menu-icon-bar2 {
  opacity: 0;
}


/* Rotate last bar */.change.menu-icon-bar3 {
  -webkit-transform: rotate(45deg) translate(-8px, -8px);
  transform: rotate(45deg) translate(-8px, -8px);
}

.show {
  opacity: 1!important;
}
<ulclass="navlist"id="navlist"><li><ahref="">Начало</a></li><li><ahref="">Планограма</a></li><li><ahref="">Запитване</a></li><li><ahref="">Реклама при нас</a></li></ul><divclass="menu-icon-black"id="menu-icon"onclick="menudrop()"><divclass="menu-icon-bar1"></div><divclass="menu-icon-bar2"></div><divclass="menu-icon-bar3"></div></div>

Post a Comment for "Javascript Onclick Function Doesnt Execute (error Log - Not Defined)"