0
I have a checkbox that even selected does not show the checkbox item. This attribute is created dynamically. See image:
When clicked it would have to be selected like this:
Follow the code when I click the checkbox:
$(document).on("click",".preco-prod-adicional",function(e)
{
e.preventDefault();
if ($(this).attr('checked') == 'checked')
{
alert('selecionado');
$(this).attr('checked',true);
var precoproduto = "";
var valortotal = "";
var subtotal = 0;
var resultadoitem = "";
var replacetotal = "";
precoproduto = $(this).val();
valortotal = $(".total-v .v-lor").text();
subtotal = somarValorTotal(precoproduto, valortotal);
replacetotal = subtotal.replace(',','.');
resultadoitem = $(".right-imagem .valor-total .total-v .v-lor").html(replacetotal);
}
else
{
$(this).attr('checked',false);
}
});
HTML from the checkbox:
<input type='checkbox' class='preco-prod-adicional' name='checkadicional' value='" + precoprodadicional[0] + "' id='" + prodadicional[i] + "'/>
Add the checkbox html too, please. And pq you check when you have already tested and the element is checked?
– Aline
<input type='checkbox' class='preco-Prod-additional' name='checkadditional' value='" + precoprodadditional[0] + "' id='" + prodadditional[i] + "'/>
– Felipe Michael da Fonseca
I put because it does not appear checked when checking. It is created dynamically. Very strange!
– Felipe Michael da Fonseca
Are you using common style or some other different style?
– Aline
No. It is in a modal being created dynamically by the following variable: +=
– Felipe Michael da Fonseca
Why change the state of
checkbox
in the click ? acheckbox
already changes default state when clicking– Isac