javascript - Changing An Elements Content -


i change content of element button click , have return original message. how preferable toggle class if possible.

<doctype html> <html> <head> <meta charset=utf-8> <title>day practice</title> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"> </script>  </head> <body> <h1> hotdogs</h1> <input type=button id=button value=button> <script> $("#button").click(function(){  $("h1").html("change this"); });   </script> 

this changes header button, don't know how revert when click on button again. maybe toggle class, don't know.

this should solve:

$( "#button" ).toggle(function() {   $("h1").html("change here"); }, function() {   $("h1").html("revert here"); }); 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -