Javascript/Jquery change class of Select after selecting option -


so have select box color grey after selecting option color of box should turn black. using following code accomplish event

$('.change_color').on("change",function() {    $(this).removeclass('grey_color');    $(this).addclass('black_color');  });
.grey_color{      color: #999;  }  .black_color{      color: #000;  }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>  <div>    <select class="change_color grey_color">  	<option>12th standard</option>  	<option>high school</option>  	<option>first year</option>    </select>  </div>

i can't seem figure out error.

seems working per requirement.

here link code: http://codepen.io/anon/pen/rrjgeo

markup:

<!doctype html>  <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head>     <meta charset="utf-8" />     <title>select box</title>     <script src="https://code.jquery.com/jquery-3.1.0.js"             integrity="sha256-slogkvb1k3vokzai8qitxv3vzponkenvskvtkylmjfk="             crossorigin="anonymous"></script>      <style>         .grey_color {             color: #999;         }          .black_color {             color: #000;         }     </style>      <script>         $(document).ready(function () {             $('.change_color').on("change", function () {                 $(this).removeclass('grey_color');                 $(this).addclass('black_color');             });         });      </script> </head> <body>     <div>         <select class="change_color grey_color">             <option>12th standard</option>             <option>high school</option>             <option>first year</option>         </select>     </div> </body> </html> 

Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -