我目前正在使用 jQuery 数据表插件,想知道是否有任何方法可以将行选择限制为 3。现在用户可以选择无限数量的行。这是我的代码的 jsfiddle:http: //jsfiddle.net/EfFA2/
JS
$(document).ready(function() {
$('#example5').dataTable( {
"bPaginate": true,
"bLengthChange": false,
"bFilter": true,
"bSort": true,
"bInfo": true,
"bAutoWidth": false
} );
/* Add/remove class to a row when clicked on */
$('#example5 tr').click( function() {
$(this).toggleClass('row_selected');
} );
} );
$('#example5').css('min-height','300');
$('.btn_r').click(function(){
$('.row_selected').removeClass('row_selected')
})