jquery - 在数据表jQuery中更改复选框状态为true的类按钮
问题描述
我使用数据表,但我遇到了问题。
在表中我有自定义复选框,我需要检查框的状态,为此我使用这个函数:
var table = $('#table').dataTable();
var rowcollection = table.$(".subUsed:checked", { "page": "all" });
rowcollection.each(function (index, elem) {
var checkboxValue = $(elem).val();
if (checkboxValue === true) {
table.find(".addSubItem").removeClass('hide')
} else {
table.find(".addSubItem").addClass("hide")
}
});
它是检查,在checkboxValue我得到一个结果,我想检查值是否为真,然后在具有类.addSubItem的按钮中删除类隐藏。
但在某些情况下,它不会被删除。
解决方案
提供了新代码,也许会对某人有所帮助:
$(document).ready(function () {
var table = $('#table').DataTable();
table.rows().every(function () {
if (this.nodes().to$().find(".input:checked").val()) {
this.nodes().to$().find(".buttonClass").removeClass('hide')
}
})
});
推荐阅读
- rust - 将 NonZeroUsize 包装在新类型中
- azure - 不满足使用 HTTP 条件标头指定的条件 Azure datalake gen2 using Python azure function
- javascript - Access-Control-Allow-Origin: 同源 & recaptcha & YouTube-视频
- android - 如何防止我的应用程序被系统杀死?
- python - 使用 pyenv 时无法添加任何带有诗歌的包
- visual-studio - 如何在 Visual Studio 中更改 UI 颜色,而不更改文本编辑器中的字体和文本颜色?
- ruby-on-rails - 检查是否调用了内部方法 - rspec
- bootstrap-4 - 如何使用 Bootstrap 进行响应式网页设计?
- r - 如何使用 ggplot 在 R 中绘制特定行?
- node.js - NextJS API 未发布到外部域