I have an post action, and when it success, i call a method and pass a the json result. Then i loop through each json object, in that loop i want to get a checkbox with objects id as a value attribute, here is how i did:
$.each(roles, function (index, role) {
var checkboxes = $('input[value="role.RoleId"][type="checkbox"]').attr("checked",true);
});
As you can see, i have a list of checkboxes and i want to select them when their value attribute is equal to “role.RoleId”. But i couldn’t manage to do it, how can i do it?
Edit: Well how can i select the wrapper element of that checkbox. it’s in . so i need also select element?
Thanks
You have to use the value or role.RoleId like this
as role is a object from $.each loop.