HTML <input> Tag with 'type=button'


<label for="principal">Amount to invest: $</label>
<input type="number" min="0" id="principal" name="principal" value="1000">
<p><label for="rate">Interest Rate: </label>
<input type="range" min="0" max="20" id="rate" name="rate" value="0" oninput="thisRate.value = rate.value">
<output name="thisRate" for="rate">0</output><span>%</span></p>
	<input type="button" onClick="amount.value = (principal.valueAsNumber * rate.valueAsNumber) / 100" value="Calculate Interest">
	<strong>$<output name="amount" for="principal rate">0</output></strong></p>


The above example demonstrates usage of the <input> element with the type attribute set to button (i.e. type="button"). We use the onClick attribute to run JavaScript when the user clicks the button.

The button value represents a button with no default behavior. You can use JavaScript to provide functionality, such as running a small script or calling a function.

The value attribute allows you to provide a label for the button.