JSFiddle - React, Tailwind, and code Playground

HTML

<table>
    <tr>
        <td class=" ">
            <input type='button' value='-' class='qtyminus' field='quantity' />
            <input type='text' name='quantity' value='5' class='qty' />
            <input type='button' value='+' class='qtyplus' field='quantity' />
        </td>
    </tr>
   
</table>

JavaScript

$('input[field="quantity"]').click(function (e) {
    e.preventDefault();
    var $this = $(this);
    var $target = $this.parent().find('.qty');
    var currentVal = parseInt($target.val());
    //check to see if we're adding one or subtracting one
    var adjustment = ($this.hasClass('qtyplus')) ? 1 : -1;
    if (!isNaN(currentVal)) {
        //check to see if adjustment would go negative if so set to 0.
        $target.val((currentVal + adjustment < 0) ? 0 : currentVal + adjustment);
    } else {
        $target.val(0);
    }
});