You can pass a function to .attr(), for example:
$('input.people').attr('checked', function() {
return this.name == 'toddS' || this.name == 'gwenD';
});
If you need to add later, you can use something that works for more values, for example $.inArray(), for example:
$('input.people').attr('checked', function() {
return $.inArray(this.name, ['toddS', 'gwenD']) != -1;
});
source
share