Been trying to convert the following to number:
You can adding a +
before the string without using parseInt and parseFloat and radix, Simply
sample:
var votevalue = +$('button').data('votevalue');
alert(typeof(votevalue));
var string = 123 (is string),
parseInt(parameter is string);
var string = '123';
var int= parseInt(string );
console.log(int); //Output will be 123.
You should just use "+" before $(this)
. That's going to convert the string to number, so:
var votevalue = +$(this).data('votevalue');
Oh and I recommend to use closest()
method just in case :)
var votevalue = +$(this).closest('.btn-group').data('votevalue');