gpt4 book ai didi

jquery - 如何在 jQuery 中将 Bootstrap 复选框附加到数据表

转载 作者:行者123 更新时间:2023-11-28 03:12:24 25 4
gpt4 key购买 nike

我正在尝试通过 jquery ajax 动态附加 Bootstrap 复选框。但只有复选框附加,我无法调用它的 Bootstrap 类。

My Code:

var checkbox = '<input type="checkbox" class="checkboxes">';
//checkboxes is my bootstrap class

$.getJSON( "ajax/test.json", function( arr_data ) {
$('#example').dataTable().fnAddData([checkbox, arr_data[i].name]);
});

作为上述代码的结果,未应用复选框类。

最佳答案

为什么不用 jQuery 的 append?我假设您正在尝试将所有内容添加到“#example”。我还假设您将从 AJAX 调用中获得不止一件事。

$.getJSON( "ajax/test.json", function( arr_data ) {
for (var i = 0; i < arr_data.length; i++) {
$('#example').append('<input type="checkbox" +class="checkboxes">'
+ arr_data[i].name)
}
});

关于jquery - 如何在 jQuery 中将 Bootstrap 复选框附加到数据表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30028816/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com