JSFiddle - React, Tailwind, and code Playground
by Zoramite
HTML
<!doctype html>
<head>
<meta charset="utf-8">
<title>Testing Button</title>
</head>
<body>
<form id="testForm" action="." method="POST">
<div id="buttonArea">
<button id="staticButton" type="button">Static Button</button>
</div>
<input type="submit" value="Submit" />
</form>
</body>
</html>
JavaScript
;(function($){
$(function(){
$('#testForm').submit(function() {
alert('Form was submitted.');
return false;
});
$('#staticButton').click(function(){
try {
this.type = 'button';
alert('using .type: ' + $(this).attr('type'));
} catch (e) {
alert('unable to use .type');
}
try {
this.setAttribute('type', 'button');
alert('using .setAttribute(): ' + $(this).attr('type'));
} catch (e) {
alert('unable to use .setAttribute()');
}
});
});
})(jQuery);