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"/>
.
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 .
$('input').prop('type','button');
You can use setAttribute property something like this in javascript
document.getElementsByName("submitform").setAttribute('type', 'button');
for jQuery
$('input[name="submitform"]').attr("type", "button");
使用jQuery:
$('input[name="submitform"]').attr('type', 'button');
用jquery:
$('input[name="submitform"]').attr('type','button')
For <input type="submit" name="submitform"/>
,
write jquery as:
<script>
$(document).ready(function(){
$('input[name="submitform"]').attr('type', 'button');
});
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.