本文实例讲述了JS拖动选择table里的单元格。分享给大家供大家参考,具体如下:
用JS 实现类似Excel里面动态选择单元格的例子,从网上得到的例子,先记录在这里,以后参考用。
www.jb51.net JS拖动选择table里的单元格 .table-container { width: 100%; overflow-y: auto; _overflow: auto; margin: 0 0 1em; background-color:white; } table { border: 0; border-collapse: collapse; } table td, table th { border: 1px solid #999; padding: .5em 1em; } .table-container::-webkit-scrollbar { -webkit-appearance: none; width: 14px; height: 14px; } .table-container::-webkit-scrollbar-thumb { border-radius: 8px; border: 3px solid #fff; background-color: rgba(0, 0, 0, .3); } .table-time div { text-align: center; min-width: 104px; } .table-time, tr th { background-color: #DBE5F1; } .table-time { cursor: default !important; } .div-right { text-align: right; } .div-unSelect { background-color: #D8D8D8; } .div-Select { background-color: #92D050; } .div-ISelect { background-color: #FBD4B4; } ul li { list-style: none; float: left; } .table-container td { cursor: pointer; }
运行效果:
感兴趣的朋友可以使用在线HTML/CSS/Javascript代码运行工具:http://tools.jb51.net/code/HtmlJsRun测试上述代码运行效果。
更多关于jQuery相关内容感兴趣的读者可查看本站专题:《jQuery表格(table)操作技巧汇总》、《jQuery操作xml技巧总结》、《jQuery form操作技巧汇总》、《jQuery常用插件及用法总结》、《jQuery扩展技巧总结》及《jquery选择器用法总结》
希望本文所述对大家jQuery程序设计有所帮助。



