感謝您的答案的傢伙,但它看起來是正確的,它適用於jsfiddle.net,但在我的代碼警報火災很好,但沒有任何反應的複選框。 :/
$('#selectChb').click(function(){
$(':checkbox').prop("checked", true);
alert("1");
});
$('#deselectChb').click(function(){
$(':checkbox').prop("checked", false);
alert("2");
});
...
<div id="chbDiv" class="ui-widget ui-widget-content ui-corner-all" > <br></br>
<table width="90%" border="0" align="center" cellpadding="5" cellspacing="0">
<tr>
<td colspan="2">Following:</td>
<td> </td>
</tr>
<tr>
<td width="25" align="left"><input type="checkbox" id="check1" /><label for="check1"> </label></td>
<td width="45" align="center"><img src="face_01.jpg" width="32" height="32"></td>
<td>Andrew Lloyd Webber</td>
</tr>
<tr>
<td width="25" align="left"><input type="checkbox" id="check2" /><label for="check2"> </label></td>
<td width="25" align="center"><img src="face_02.jpg" width="32" height="32"></td>
<td>Richard Branson</td>
</tr>
<tr>
<td width="25" align="left"><input type="checkbox" id="check3" /><label for="check3"> </label></td>
<td width="25" align="center"><img src="face_03.jpg" width="32" height="32"></td>
<td>Dmitry Medvedev</td>
</tr>
</table>
<br>
<table width="90%" border="0" align="center" cellpadding="5" cellspacing="0">
<tr>
<td><a href="#" id="selectChb" class="ui-state-default ui-corner-all"><span class="ui-icon ui-icon-check"></span>Select All</a>
<a href="#" id="deselectChb" class="ui-state-default ui-corner-all"><span class="ui-icon ui-icon-close"></span>Deselect All</a></td>
<td> </td>
<td> </td>
</tr>
</table>
<br>
</div>
<br>
<div class="ui-widget ui-widget-content ui-corner-all">
你正在測試什麼瀏覽器和jQuery版本? – 2011-06-03 21:10:45
FireFox,最新版本的jQuery,1.6.1 – Roger 2011-06-04 06:53:25