I have an input button. I created for this input an attribute called \"multiplicateur\" which has the value of 1. When the button is clicked I have a .click()
t
In order to add value with decimal point, please use parseFloat(ajaxData)
alert(parseFloat(ajaxData) + 1);
ajaxData
is a string
. Thus, you need to parse it to an integer
...
$('#envoyer').click(function() {
const ajaxData = $(this).attr('multiplicateur');
/* parse string to integer */
alert(parseInt(ajaxData) + 1);
});
For substracting
function removeFromQtt(){
$("qty").value = parseInt($("qty").value)-1;
}
For addition
function add(){
$("qty").value = parseInt($("qty").value)+1;
}
You have to parse it first:
parseInt(ajaxData)+1;