html:
<form id="form" action="/" method='post'>
<button>Button</button>
<input type="text">
<input type="submit" id="send-form" value="Send">
</form>
js:
$('#form').submit(function() {
console.log('send');
return false;
});
Why when I press the Button, the form is submitted (I need this element for another action)? How to prevent this?
The default action for
<button>is to be a submit button, but you can have it just be a “normal button” by doing the following:See the HTML specs for more info.