Esta es mi función y no funciona, Mis casillas de verificación permanecen sin marcar
$(document).ready(function() { var sales_agent_prev_arr = ['21-1', '21-2', '21-3', '21-5', '21-6', '26-1', '26-2', '26-3', '8-1', '8-9', '8-2', '8-3', '8-4', '8-5', '13'] $('#user_type').on('change', function() { if ($(this).val() == 6) { $('input[type="checkbox"]').each(function() { if ($.inArray(this.value, sales_agent_prev_arr) !== -1) { $(this).prop('checked',true); } }); } }) }); <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <ul> <li><input type="checkbox" value="21-1">View All</li> <li><input type="checkbox" value="21-2">check</li> </ul>Verifique las dos líneas de su código, sin ellas funciona bien:
$('#user_type').on('change', function() { if ($(this).val() == 6) {