Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.
Date: 2015jan29 Language: html Q. How can I avoid an html <button> from causing a submit of the form? I have:<button onClick="doSomething()">Do Something</button>How can I avoid it submitting the form its in? A. You need to add type=button (yes, that seems redundant) like this:<button type=button onClick="doSomething()">Do Something</button>
Add a commentSign in to add a comment