javascript - 如何在响应式显示的一行上添加一个类?
问题描述
我正在尝试在用户单击的行上添加一个类。为此,我使用responsive-display
事件。
$(function () {
$('#people-waiting-send-up').DataTable().on('responsive-display', function (e, datatable, row, showHide, update) {
row.addClass('opened')
});
});
但row
不是 jQuery 对象,所以addClass()
不起作用。我应该怎么做?
解决方案
使用row.index
,我可以找到用户单击的行,并为其添加一个类:
$(function () {
$('#people-waiting-send-up').DataTable().on('responsive-display', function (e, datatable, row, showHide, update) {
$(datatable.row(row.index()).node()).addClass('opened');
});
});
推荐阅读
- reactjs - 组件被卸载并在 DOM 中的不同位置渲染它时调用构造函数
- push-notification - iOS 应用程序在重新连接到互联网时停止接收通知
- html - VueJS 导航栏链接只有在浏览器中缩小后才能点击
- python - 使用 for in 循环时将项目移动到列表的前面
- reactjs - 如何使组件在他们接受的道具中明确?
- azure - Nginx拒绝ssh,锁在外面
- scala - 面临错误“无法加载 PDF 文档”。在scala中发送pdf文件作为字节数组作为响应(scala)
- xcode - 我可以摆脱签名部分吗?(沙盒与强化运行时)
- python - 如何从图像字段中删除/替换文件
- python - Jupyter笔记本不显示图表..(只是图表)