作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试通过 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/
我是一名优秀的程序员,十分优秀!