I have a conditional that must check or uncheck an input checkbox, but it doesn't work, and I don't know what to do. I have searched and tried some jquery checkbox manipulation options, but any of them work. With a console log messages I know that the conditional works and the input checkbox is accessible. Please, give me a hand.
if(parseInt(permiso_acceso)==1) {
var valor = $('#permiso_acceso').val();
console.log('Must be checked '+valor);//It works
$('#permiso_acceso').attr('checked',true);
} else {
var valor = $('#permiso_acceso').val();
console.log('Must be unchecked '+valor);//It works
$('#permiso_acceso').attr('checked',false);
}