jQuery拖动调整表格列宽度-resizableColumns

该博客介绍了如何使用jQuery实现表格列宽的拖动调整功能,通过引入jquery.resizableColumns.js和store.js文件,调用$("#myTable").resizableColumns()方法即可实现。提供了相关文件的下载链接,并提到了若未能达到预期效果可考虑使用colResizable插件作为替代方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

实现鼠标可拖动调整表格列宽度 如图:


一、引入文件:

<script src="/js/jquery-1.8.0.min.js" type="text/javascript"></script>
<script src="/js/store.js" type="text/javascript"></script>
<script src="/js/jquery.resizableColumns.js" type="text/javascript"></script>

二、TABLE

<table id="myTable" border="1"> 
   <thead> 
    <tr> 
     <th data-resizable-column-id="a"><input type="checkbox" /></th> 
     <th data-resizable-column-id="b">栏目类型 </th> 
     <th data-resizable-column-id="c">活动名称 </th> 
     <th data-resizable-column-id="d">状态 </th> 
     <th data-resizable-column-id="e">操作选项</th> 
    </tr> 
   </thead> 
   <tbody> 
    <tr> 
     <td><input type="checkbox" /></td> 
     <td>青春日记</td> 
     <td>2014年度青春日记征文 </td> 
     <td>提交 </td> 
     <td>审核</td> 
    </tr> 
    <tr> 
     <td><input type="checkbox" /></td> 
     <td>我和孩子的成长故事</td> 
     <td>成长故事 </td> 
     <td>通过 </td> 
     <td>审核</td> 
    </tr> 
   </tbody> 
</table>
以上html只是作为Demo 并不是我项目中所实际使用的,并且在测试的时候   也未能实现。郁闷...


三、实现表格可拖动

<script type="text/javascript">
    $(function(){
	$("#myTable").resizableColumns({
	     store: window.store
	});
    })
</script>

在项目使用过程中 发现无需引入store.js <th>也无需data-resizable-column-id属性

并且$("#myTable").resizableColumns();也可实现功能

所需文件下载地址:http://download.youkuaiyun.com/detail/itmyhome/7390263

分别解压两个文件

jquery.resizableColumns.js在\jquery-resizable-columns-gh-pages\dist路径下

store.js在store.js-master路径下


------------------------分割线----------------------------


如果未实现效果,可使用 colResizable 插件

参考: http://blog.itmyhome.com/2016/05/jquery-colresizable  


                                                                             2016-05-05

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值