如何使用jQuery在具有复选框列表的表(jsp页面内)中启用ctrl+A(check-all选项)?
谢谢
Matt
这为您可以用作示例的功能提供了poc:http://jsfiddle.net/HVxss/1/
<input type="checkbox"/>
<input type="checkbox"/>
<input type="checkbox"/>
<div id="test">Select All</div>
$("#test").click(function(){
$("input[type='checkbox']").prop("checked", true);
});
您可以添加一个类似"全选"的复选框,然后在用户选中时使用以下jQuery来选中所有复选框。
$(document).ready(function() {
$('input.checkall).change(function() {
if ($(this).is(':checked')) {
$(this).closest('ul').siblings('input:checkbox').attr('checked', true);
}
});
});
http://api.jquery.com/keypress/
使用javascript
<script language="javascript" type="text/javascript">
window.addEvent( 'keydown', function( evt ){
if( evt.key == 'enter' && evt.shift )
//code to chck all option
});
</script>