How to set submit button text using jQuery?

For some reason, $("#thebutton").val("New text") not working.

+4
source share
2 answers

Well, this works for me (tested on Chrome 4, FireFox 3.6, IE8):

 <html> <head> <title>Test</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script> <script type="text/javascript"> $(function() { $("#thebutton").val("New text"); }); </script> </head> <body> <input id="thebutton" type="submit" value="OK" /> </body> </html> 
+18
source

If you use the html button ie <button id='thebutton ' > Button Val </button> then use $("#thebutton").text("NEW Text");

+2
source

Source: https://habr.com/ru/post/1301794/


All Articles