jquery - Change Div Style by using JavaScript without page reloading -


i tried change background color div using javascript, changes didn't applied because when press on button browser make reload page , restore default setting without change.

how can change background color div without page reload or changes applied?

here's code using jquery changes background without reloading:

<!doctype html> <html> <head>   <meta charset="utf-8">   <title>changing div background color</title>   <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>   <style>   #changing_background {     background-color: red;     min-height: 200px;   }   </style> </head> <body>  <div id="changing_background"></div>  <button id="change_background">click me</button>  <script>   $("#change_background").click(function(e){     $("#changing_background").css("background-color", "blue");   }); </script>  </body> </html> 

Comments

Popular posts from this blog

symfony - TEST environment only: The database schema is not in sync with the current mapping file -

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -