JSFiddle - React, Tailwind, and code Playground

by TheBanana

HTML

<form id="my-form">
    <input type="email" name="email" placeholder="(Your email)" />
    <button type="submit" value="button-one">Go - One</button>
    <button type="submit" value="button-two">Go - Two</button>
    <button type="submit" value="button-three">Go - Three</button>
</form>

JavaScript

$(function () {
    $("#my-form button").click(function (ev) {
        ev.preventDefault() // cancel form submission
        if ($(this).attr("value") == "button-one") {
            //do button 1 thing
            alert("Button One Pressed, submitting form")
            $("#my-form").submit();
        }
        if ($(this).attr("value") == "button-two") {
            alert("Button Two Pressed, NOT SUBMITTING")
        }
        if ($(this).attr("value") == "button-three") {
            alert("Button Three Pressed, NOT SUBMITTING")
        }
    });
});