This post will discuss how to change the value of the <input> element of type button or submit in JavaScript and jQuery.

1. Using jQuery

With jQuery, you can use the .val() method to set values of the form elements. To change the value of <input> elements of type button or type submit (i.e., <input type="button"> or <input type="submit">), you can do like:

JS


HTML


CSS



Edit in JSFiddle

 
Alternatively, you can use jQuery’s .prop() method.

JS


HTML


CSS



Edit in JSFiddle

2. Using JavaScript

With JavaScript, you can modify the <input> elements’ value attribute, which contains a DOMString used as the button’s label.

JS


HTML


CSS



Edit in JSFiddle

That’s all about changing the value of a button in JavaScript and jQuery.