jQuery - 使所有表格单元格可拖动,除了每行中的第一个单元格
我不知道如何使表格中的所有单元格可拖动,除了每行中的第一个单元格。我认为这可能有效:
$("#tableid tbody tr td:not(:first)").draggable({
connectToSortable: "#sortable",
helper: "clone",
revert: "invalid"
});
或者这样:
$("#tableid tbody tr td").not("#tableid tbody tr td:first").draggable({
connectToSortable: "#sortable",
helper: "clone",
revert: "invalid"
});
但这两者都只是阻止第一行的第一个单元格可拖动。不是每一行...
有什么想法吗?
I cannot figure out how to make all cells in a table draggable, except the first cell in each row. I thought this might work:
$("#tableid tbody tr td:not(:first)").draggable({
connectToSortable: "#sortable",
helper: "clone",
revert: "invalid"
});
Or this:
$("#tableid tbody tr td").not("#tableid tbody tr td:first").draggable({
connectToSortable: "#sortable",
helper: "clone",
revert: "invalid"
});
But both just stops the first cell of the first row being draggable. Not every row...
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要选择除每行第一个
td
之外的所有内容,您需要:在此处进行测试:http://jsfiddle.net/KsUCj/
通过调用
:first
您将找到整个集合中的第一个元素。另外,如果您将每行中的第一个单元格视为特殊的,那么听起来您可能实际上需要这个标记:
这不仅更具语义性,而且为您的行头的 CSS 样式提供了更好的挂钩,而且您会还没有遇到这个问题,因为
tbody tr td
已经选择了除第一列之外的所有列。To select all but the first
td
per row, you want:Test it out here: http://jsfiddle.net/KsUCj/
By calling
:first
you are finding the first element in the entire set.Also, if you are treating the first cell in each row as special, it sounds like you might actually want this markup instead:
Not only is this more semantic, and provides you better hooks for your CSS styling of the row heads, but you would not have run into this problem as
tbody tr td
would select all but the first column already.难道不应该是“tr:first td”而不是“tr td:first”吗?
Shouldn't that be 'tr:first td' as opposed to 'tr td:first'?