http://jsfiddle.net/leongaban/fhhmLfab/
In the example above I have 3 buttons, orange, green and red.
On hover each reveals a [ - ] and a [ + ] button with a class of btn_action
.
On click I'm trying to grab the numerical value from the target color button and then increment or decrement it by 1.
Currently I'm getting NaN on my parseInt function:
$('.btn_action').unbind('click').bind('click', function() {
var type = $(this).data('type').toString();
console.log(color);
console.log(type);
// this is returning NaN, it should be returning 1:
var number = parseInt($('option_'+color).text(), 10);
console.log(number);
if (type === 'plus') {
// number = number + 1;
$('option_'+color).text(number + 1);
console.log(number);
}
});
Thoughts on where I'm going wrong?