[Demo] CheckBox Click When Disabled
[Demo] CheckBox Click When Disabled
by dying_sakura
HTML
<table>
<tbody>
<tr class="row">
<td>
<select>
<option value="1">Option 1 of row 1</option>
<option value="2">Option 2 of row 1</option>
<option value="3">Option 3 of row 1</option>
</select>
</td>
<td>
<select>
<option value="1">Option 1 of row 1</option>
<option value="2">Option 2 of row 1</option>
<option value="3">Option 3 of row 1</option>
</select>
</td>
.....
.....
<tr>
<tr class="row">
<td>
<select>
<option value="a">Option a of row 2</option>
<option value="b">Option b of row 2</option>
<option value="c">Option c of row 2</option>
</select>
</td>
<td>
<select>
<option value="a">Option a of row 2</option>
<option value="b">Option b of row 2</option>
<option value="c">Option c of row 2</option>
</select>
</td>
<tr>
</tbody>
</table>
JavaScript
$('.row select').change(function(){
var values = [];
$(this).closest('tr').find('select').each(function(){
if(this.value.length > 0)
values.push(this.value);
});
$(this).closest('tr').find('select').find('option').each(function(){
if($.inArray(this.value, values) > -1 && !this.selected)
$(this).attr("disabled","disabled");
else
$(this).removeAttr("disabled");
});
});
$('.row select').change();