A wordpress plugin sets a number field, I'm unable to add extra HTML before and after the number field. I've already added some CSS to remove the default arrows.
So I've added two elements with jQuery before and after the input:
$('.enviso-group-form .quantity input').each(function(i, obj) {
$(this).before('<span class="selectNumber__increase selectNumber__change">+</span>');
$(this).after('<span class="selectNumber__decrease selectNumber__change">-</span>');
$(this).val(0);
});
The code above loops over each input, adds two spans and sets the value to 0. Until now, everything works. This is what it looks like:
I've also created a function to increment the value of the number input:
$('.enviso-group-form .selectNumber__increase').on('click', function(e) {
$oldValue = $(this).find('input').val();
$newValue = parseInt($oldValue) + 1;
console.log(parseInt($newValue));
$(this).next('input').val($newValue);
});
This unfortunately doesn't work. It triggers the console.log but I get NaN and the input value stays 0.
