$(function() { $('.all-select').click(function() { console.log('allselect'); var index = $(this).attr('id').substring(10); console.log(index); $('.area' + index).each(function(i) { $(this).attr('checked', true ); }); }); function allselect() { } });