Привет, ребята, я создаю этот проект для игры, поэтому мне нужно увеличить значение, чтобы изменить одежду, но когда я нажимаю кнопку, я получаю нулевое значение
код js
$('.button-left').on('click', function () {
var input = $(this).parent().find('.input-number')
input.val(parseInt(input.val()) - 1)
clotheedit('tshirt_', input)
})
$('.button-right').on('click', function () {
var input = $(this).parent().find('.input-number')
input.val(parseInt(input.val()) + 1)
clotheedit('tshirt_', input)
})
функция clotheedit
function clotheedit(type,value) {
var values = parseInt(value);
if(type == 'arms'){
$('#'+type+'2').text(value);
$('#'+type+'_22').text(0);
$('#'+type+'_2').prop('value',0);
var type1 = type;
var type2 = type+'_2';
}else if(type == 'hair_1'){
$('#'+type+'2').text(value);
$('#hair_color_12').text(0);
$('#hair_color_1').prop('value',0);
var type1 = type;
var type2 = 'hair_color_1';
$.post('http://bh-skin/maxcolor', JSON.stringify({type:'hair_2'}));
}else if(type == 'hair_2'){
$('#'+type+'2').text(value);
$('#hair_color_22').text(0);
$('#hair_color_2').prop('value',0);
var type1 = type;
var type2 = 'hair_color_2';
}else{
$('#'+type+'12').text(value);
$('#'+type+'22').text(0);
$('#'+type+'2').prop('value',0);
var type1 = type+'1';
var type2 = type+'2';
}
$.post('http://bh-skin/value', JSON.stringify({value:values,type:type1}));
$.post('http://bh-skin/value', JSON.stringify({value:0,type:type2}));
$.post('http://bh-skin/maxcolor', JSON.stringify({type:type2}));
}
html кнопка, которая прослушивает это событие
<button class="button-left col s4 waves-effect waves-light btn">
<i class="material-icons">chevron_left</i>
</button>
, поэтому проблема в js, когда я нажимаю на кнопку, я получаю нулевое значение для этот вход
clotheedit('tshirt_', input)
любая помощь?