javascript - Can't load jQuery codes -


i'm absolute beginner in web development. have html, css , javascript file. want change background color of button, unfortunately doesn't work. files (including jquery library) placed in folder. clue appreciated.

html file:

<html>   <head>     <link rel="stylesheet" type="text/css" href="style.css">     <script src="jquery-3.1.0.min.js"></script>      <script src="code.js"></script>   </head>   <body>     <button class="button">click!</button>   </body> </html> 

css file:

.button {     background-color: #4caf50;     border: none;     color: white;     padding: 15px 32px;     text-align: center;     text-decoration: none;     display: inline-block;     font-size: 16px;     margin: 4px 2px;     cursor: pointer; }  .button_clicked {     background-color: #ff0000; } 

javascript codes:

var clicked = function(){     $('.button').clicked(function(){         $(this).toggleclass("button_clicked");     }); };  $(document).ready(clicked); 

it simple typo. notice variable name defined clicked function in jquery click(). if make following change should work fine:

var clicked = function(){ $('.button').click(function(){     $(this).toggleclass("button_clicked"); }); };  $(document).ready(clicked); 

Comments