How to change the type attribute from submit
to button
using JavaScript or jQuery? I use an input
element like <input type="submit" name="submitform"/>
.
The <button> tag with a type="submit" attribute creates a submit button.
The value attribute can be used to change the text of the form submit button. Use value attribute within <input> of type="submit" to rename the button.
The type attribute specifies the type of button. Tip: Always specify the type attribute for the <button> element. Different browsers may use different default types for the <button> element.
Change the property of the native DOM node:
document.getElementsByName("submitform")[0].type = "button";
Do it with jQuery:
$("input[name='submitform']").prop("type", "button");
But remember that you cannot change input
types in Internet Explorer 8 and below.
You can use setAttribute property something like this in javascript
document.getElementsByName("submitform").setAttribute('type', 'button');
for jQuery
$('input[name="submitform"]').attr("type", "button");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With