I have the following function:
function alteraSaldo(item){
saldo = parseInt($('#saldo').val());
campo = $('#'+item);
if (campo.checked == true){
alert('sim');
saldo = saldo - parseInt(campo.data("valor"));
}else{
alert('nao');
saldo = saldo + parseInt(campo.data("valor"));
}
$('#saldo').val(saldo);
}
I call it in the onclick event of the checkbox:
<input type="checkbox" data-valor="28.00" id="mensalidade9" onclick="alteraSaldo('mensalidade9');" />
The function recognizes the checkbox, as it shows the correct value, but always shows that it is NOT "checked".
What can it be?