javascript - Can't get JS to run -


this question has answer here:

i found slider menu on codepen liked no matter can't js run. tried multiple sources of code , none worked properly.

<html> <head>     <title>aos slide</title>     <link rel="stylesheet" type="text/css" href="slide-test.css">     <script src="slidetest.js"></script> </head>  <div id="button" class="button">     <div></div>     <div></div>     <div></div>   </div>   <div id="menu" class="none">     <nav>       <ul>         <li class="menu-item">           <a href="" class="link">home</a>         </li>         <li class="menu-item">            <a href="file:///users/scatman01/desktop/code/aos3.0/aos-hike.html">hike</a>         </li>         <li class="menu-item">           <a href="file:///users/scatman01/desktop/code/aos3.0/aos-bike.html">bike</a>         </li>         <li class="menu-item">           <a href="file:///users/scatman01/desktop/code/aos3.0/aos-fishing.html">fishing</a>         </li>         <li class="menu-item">           <a href="file:///users/scatman01/desktop/code/aos3.0/aos-run.html">run</a>           <li role="separator" class="divider"></li>         </li><li class="menu-item">           <a href="file:///users/scatman01/desktop/code/aos3.0/aos-triplecrown.html">triple crown</a>           <li role="separator" class="divider"></li>         </li><li class="menu-item">           <a href="file:///users/scatman01/desktop/code/aos3.0/aos-gallery.html">gallery</a>         </li><li class="menu-item">           <a href="" class="link">contact</a>         </li>       </ul>     </nav>   </div>   <div id="shadow" class="none"></div> </body> </html> 

css:

html {   height: 100%;  }  body {   height: 100%;   margin: 0;   padding: .1px;   position: relative;   background: url(http://www.adventuresofscatman.com/wp-content/uploads/2015/09/img_4273.jpg);   background-size: cover;   overflow-x: hidden; }  .button{   position: absolute;   top: 30px;   left: 25px;;   width: 55px;   height: 50px; }  .button div {   height: 20%;   border-top: 7px solid rgb(103, 103, 103);   cursor: pointer;   transition: .5s; }  .button:hover div {   border-color: rgb(139, 139, 139);  }  .menu-in, .menu-out {   padding: .1px;   width: 240px;   height: 100%;   background: rgba(0, 0, 0, .65);   overflow: hidden;   position: absolute;   top: 0; }  .menu-in {   -webkit-animation: menu-in .9s forwards ease; }  .menu-out{   -webkit-animation: menu-out .4s forwards ease-in;  }  ul {   margin: 68px 0 0 0;   padding: 0; }  .menu-item {   list-style: none; }  .link {   display: block;   text-decoration: none;   color: rgb(190, 190, 190);   font: 28px/50px arial;   text-transform: uppercase;   height: 50px;   text-align: center;   transition: .1s; }  .link:hover {   color: rgb(230, 230, 230);   background: rgba(200, 200, 200, .1);  }  .shadow-in, .shadow-out{   width: 100%;   height: 100%;   position: absolute;   top: 0;   background: rgba(0, 0, 0, .4); }  .shadow-in {   -webkit-animation: shadow-in .9s forwards ease; }  .shadow-out {    -webkit-animation: shadow-out .4s forwards ease-in; }  .none {   display: none; }  @-webkit-keyframes menu-in {   0% {     left: -240px;   }   100% {     left: 0;   } }  @-webkit-keyframes menu-out {   0% {     left: 0;   }   100% {     left: -240px;   } }    @-webkit-keyframes shadow-in {   0% {     left: 0;     opacity: 0;   }   100% {     left: 240px;     opacity: 1;   } }  @-webkit-keyframes shadow-out {   0% {     left: 240px;     opacity: 1;   }   99%{     height: 100%;    }   100% {     height: 0;     left: 0;     opacity: 0;   } } 

js:

document.getelementbyid('button').addeventlistener('click', function() {     showmenu(); });  document.getelementbyid('menu').addeventlistener('click', function() {     showmenu(); });  function showmenu() {     console.log('click');     var menu = document.getelementbyid('menu');     var shadow = document.getelementbyid('shadow');     var button = document.getelementbyid('button');      menu.classname = 'menu-in';     shadow.classname = 'shadow-in';     button.classname = 'none'; }  document.getelementbyid('shadow').addeventlistener('click', function() {     var menu = document.getelementbyid('menu');     var shadow = document.getelementbyid('shadow');     var button = document.getelementbyid('button');      menu.classname = 'menu-out';     shadow.classname = 'shadow-out';     button.classname = 'button'; }); 

i'm quite new javascript myself, though must ran similar issue yours before. couldn't external javascript file work. figured out needed separate jquery library hosted google in .html file in order make work.

i not sure 1 need (or if need any), can't no harm looking hosted libraries google , paste link between <script></script> tags above closing tag of body.

a small example of coding (might idea):

<!doctype html>  <html>    <head>    <title></title>    <link rel="stylesheet" type="text/css" href="css/style.css">  </head>    <body>    <div class="content">      <div class="parallax-bg">        <h1>hello everybody</h1>      </div>    </div>      <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>    <script type="text/javascript" src="js/scrolling.js"></script>  </body>    </html>


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -