是否可以使用 jquery 根据其 id 锁定列?我见过不同的解决方案,例如标题锁定,有些还可以锁定从左侧开始索引的列。我想要做的是当我单击锁定按钮时,它将锁定列并且在水平滚动时不会移动。
例如,我单击标题 1 上的锁定,水平滚动,然后单击标题 3 上的锁定。标题 1 和标题 3 应该彼此相邻,并且在水平滚动时不应移动。
下面是我的代码:
<div style="float: left; width: 75%; overflow-x: scroll;">
<table style="width: 200% !important;">
<tr>
<td id="lid_1" colspan="3">
<div style="margin-top: 3px;">
January 24, 2013
<button id="lid_1">Lock</button>
</div>
</td>
<td id="lid_2" colspan="3">
<div style="margin-top: 3px;">
January 25, 2013
<button id="lid_2">Lock</button>
</div>
</td>
<td id="lid_3" colspan="3">
<div style="margin-top: 3px;">
January 26, 2013
<button id="lid_3">Lock</button>
</div>
</td>
<td id="lid_4" colspan="3">
<div style="margin-top: 3px;">
January 27, 2013
<button id="lid_4">Lock</button>
</div>
</td>
<td id="lid_5" colspan="3">
<div style="margin-top: 3px;">
January 27, 2013
<button id="lid_5">Lock</button>
</div>
</td>
<td id="lid_6" colspan="3">
<div style="margin-top: 3px;">
January 28, 2013
<button id="lid_6">Lock</button>
</div>
</td>
</tr>
<tr>
<td id="lid_1">Header 1</td>
<td id="lid_1">Header 2</td>
<td id="lid_1">Header 3</td>
<td id="lid_2">Header 1</td>
<td id="lid_2">Header 2</td>
<td id="lid_2">Header 3</td>
<td id="lid_3">Header 1</td>
<td id="lid_3">Header 2</td>
<td id="lid_3">Header 3</td>
<td id="lid_4">Header 1</td>
<td id="lid_4">Header 2</td>
<td id="lid_4">Header 3</td>
<td id="lid_5">Header 1</td>
<td id="lid_5">Header 2</td>
<td id="lid_5">Header 3</td>
<td id="lid_6">Header 1</td>
<td id="lid_6">Header 2</td>
<td id="lid_6">Header 3</td>
</tr>
<tr>
<td id="lid_1" colspan="3">
<table style="width:100.1%; margin-top: -17px !important; margin-left: -1px !important;">
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<br/>
</table>
</td>
<td id="lid_2" colspan="3">
<table style="width:100.1%; margin-top: -17px !important; margin-left: -1px !important;">
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<br/>
</table>
</td>
<td id="lid_3" colspan="3">
<table style="width:100.1%; margin-top: -17px !important; margin-left: -1px !important;">
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<br/>
</table>
</td>
<td id="lid_4" colspan="3">
<table style="width:100.1%; margin-top: -17px !important; margin-left: -1px !important;">
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<br/>
</table>
</td>
<td id="lid_5" colspan="3">
<table style="width:100.1%; margin-top: -17px !important; margin-left: -1px !important;">
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<br/>
</table>
</td>
<td id="lid_6" colspan="3">
<table style="width:100.1%; margin-top: -17px !important; margin-left: -1px !important;">
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<br/>
</table>
</td>
</tr>
</table>