How to make an addition instead of a concatenation

后端 未结 4 1304
遥遥无期
遥遥无期 2020-12-21 00:53

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

4条回答
  •  清歌不尽
    2020-12-21 01:40

    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);
    
    });
    

提交回复
热议问题