我希望能够在Datatables中一次只选择1个复选框。仅在数据表中选择一个复选框行
在下面的例子中,可以选择多行。我怎么能一次只选择一行?
http://datatables.net/examples/api/form.html
我希望能够在Datatables中一次只选择1个复选框。仅在数据表中选择一个复选框行
在下面的例子中,可以选择多行。我怎么能一次只选择一行?
http://datatables.net/examples/api/form.html
你可以使用单选按钮而不是复选框。
实施例:
<input type="radio" name="fieldName" value="check1" />
<input type="radio" name="fieldName" value="check2" />
<input type="radio" name="fieldName" value="check3" />
<input type="radio" name="fieldName" value="check4" />
的“name”属性是什么基团单选按钮一起时,“value”属性是什么将区分。
可以请你分享一个例子吗? – rmoh21
您应该使用单选按钮,
<form action="path/to/form_submit_script.php" method="get">
<input type="radio" name="red" value="Red" /> Red<br />
<input type="radio" name="blue" value="Blue" /> Blue<br />
<input type="radio" name="green" value="Green" /> Green<br />
<input type="submit" value="Submit">
</form>
这里是工作示例jsfiddle example
How to select first row of the first table in an html page using jQuery? 选择一个在给定的表行。 你可以使用jQuery来实现它。
var _MainDataTable = $('#dataTable').DataTable();
...
$("#dataTable").on('click', 'tr', function() {
if (_MainDataTable.$(".selected").length > 1) {
_MainDataTable.$(".selected").removeClass('selected');
$(this).addClass("selected");
}
});
http://stackoverflow.com/questions/838880/how-to-select-first-row-of-the-first-table-in-an-html-page-using-jquery 你可以使用jQuery来实现它。 – rl99
这是你想要实现的吗? https://datatables.net/extensions/select/examples/initialisation/checkbox.html – Bindrid