jQuery draggable table elements(jQuery可拖动表格元素)
问题描述
jQuery 的 draggable
功能似乎不适用于表格(在 FF3 或 Safari 中).很难想象这会如何工作,所以它不工作也就不足为奇了.
jQuery's draggable
functionality doesn't seem to work on tables (in FF3 or Safari). It's kind of difficult to envision how this would work, so it's not really surprising that it doesn't.
<html>
<style type='text/css'>
div.table { display: table; }
div.row { display: table-row; }
div.cell { display: table-cell; }
</style>
<script src="aHR0cDovL2NvZGUuanF1ZXJ5LmNvbS9qcXVlcnktbGF0ZXN0Lmpz"></script>
<script src="aHR0cDovL2Rldi5qcXVlcnkuY29tL3ZpZXcvdGFncy91aS9sYXRlc3QvdWkvdWkuY29yZS5qcw=="></script>
<script src="aHR0cDovL2Rldi5qcXVlcnkuY29tL3ZpZXcvdGFncy91aS9sYXRlc3QvdWkvdWkuZHJhZ2dhYmxlLmpz"></script>
<script>
$(document).ready(function(){
$(".row").draggable();
});
</script>
<body>
<div class='table'>
<div class='row'>
<div class='cell'>Foo</div>
<div class='cell'>Bar</div>
</div>
<div class='row'>
<div class='cell'>Spam</div>
<div class='cell'>Eggs</div>
</div>
</div>
<table>
<tr class'row'><td>Foo</td><td>Bar</td></tr>
<tr class='row'><td>Spam</td><td>Eggs</td></tr>
</table>
</body>
</html>
我想知道 a) 是否有任何特定原因导致这不起作用(从 w3c/HTML 规范的角度来看)以及 b) 获取可拖动表格行的正确方法是什么.
I'm was wondering a) if there's any specific reason why this doesn't work (from a w3c/HTML spec perspective) and b) what the right way to go about getting draggable table rows is.
我喜欢真正的表格,因为它有边框折叠和行高算法——任何可以做这些事情的替代方案都可以正常工作.
I like real tables because of the border collapsing and row height algorithm -- any alternative that can do those things would work fine.
推荐答案
如果你有真正的表格数据,你确实应该坚持使用表格.
If you have truly tabular data, you should stick with table indeed.
如果你想在表格中拖动行,这个JQuery + "可拖动行表" 库 在 FireFox3 中完美运行
And if you want to drag rows within a table, this JQuery + "draggable row table" library works perfectly in FireFox3
这篇关于jQuery可拖动表格元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:jQuery可拖动表格元素


- 为什么我的页面无法在 Github 上加载? 2022-01-01
- 使用 iframe URL 的 jQuery UI 对话框 2022-01-01
- 在不使用循环的情况下查找数字数组中的一项 2022-01-01
- 从原点悬停时触发 translateY() 2022-01-01
- 我不能使用 json 使用 react 向我的 web api 发出 Post 请求 2022-01-01
- 为什么悬停在委托事件处理程序中不起作用? 2022-01-01
- 如何向 ipc 渲染器发送添加回调 2022-01-01
- 如何调试 CSS/Javascript 悬停问题 2022-01-01
- 如何显示带有换行符的文本标签? 2022-01-01
- 是否可以将标志传递给 Gulp 以使其以不同的方式 2022-01-01