2

我有一个可拖动的表格,它工作正常,但我希望能够从<th>表格内的行中拖动它,而不是从所有<td>的。

<table id="draggable">
<tr>
<th id="drag">header (can drag table from here)</th>
</tr>
<tr>
<td>normal column (can't drag the table from here)</td>
</tr>
</table>
<script type="text/javascript">
    $( "#draggable" ).draggable({ opacity: 0.5 });
</script>

我该如何处理这个?

4

1 回答 1

4

Hiya在这里工作演示:http : //jsfiddle.net/rAzL8/ & http://jsfiddle.net/rAzL8/1/

Cooleos,所以你需要在你的桌子上使用可拖动和宾果游戏标签上的:handle属性,th它只会处理你的桌子的标签。希望这会有所帮助,干杯

jQuery代码

    $( "#draggable" ).draggable({ opacity: 0.7, handle:'#drag' });

 ​

HTML

<table id="draggable">
<tr>
<th id="drag">header (can drag table from here)</th>
</tr>
<tr>
    <td>normal column (can't drag the table from here) ;)</td> <td>another</td>
</tr>

    <tr>
<td>normal column (can't drag the table from here) ;) </td>
</tr>

    <tr>
<td>normal column (can't drag the table from here);) </td>
</tr>
</table>​
于 2012-04-08T01:23:29.213 回答