I have two buttons which allow a user to click on one to do some calculation. I need to get the button that is clicked value and store it in a SQL Server table.
I am trying to do as below but it's not working:
vSubstract: $("input[name='vSubstract']:click").val();
<input id="vSubstract" name="vSubstract" type="button" value="-">
<input id="vplus" name="vplus" type="button" value=" ">
Any help will be appreciated
CodePudding user response:
If you are using jQuery, then you are doing it wrong way, You can do something like below:
$('input[name="vSubstract"]').on('click', function(){
var val = $(this).val();
console.log(val);
});