实现类似资源管理器一样的选择方案
按住ctrl加选,按住shift连选,
active是选中后的CSS效果,自行设计或更改var lastChecked;<br>
$('#example tbody').on("click","tr", function(event) {<br>
<br>
if(!lastChecked) {<br>
lastChecked = this;<br>
}<br>
<br>
if(event.shiftKey) {<br>
var start = $('#example tbody tr').index(this);<br>
var end = $('#example tbody tr').index(lastChecked);<br>
<br>
for(i=Math.min(start,end);i
if (!$('#example tbody tr').eq(i).hasClass('active')){<br>
$('#example tbody tr').eq(i).addClass("active");<br>
}<br>
}<br>
<br>
//清楚浏览器光标选择<br>
if (window.getSelection) {<br>
if (window.getSelection().empty) { // Chrome<br>
window.getSelection().empty();<br>
} else if (window.getSelection().removeAllRanges) { // Firefox<br>
window.getSelection().removeAllRanges();<br>
}<br>
} else if (document.selection) { // IE<br>
document.selection.empty();<br>
}<br>
} else if ((event.metaKey || event.ctrlKey)){<br>
$(this).toggleClass('active');<br>
} else {<br>
$('#example tbody tr').removeClass('active');<br>
$(this).toggleClass('active'); <br>
}<br>
<br>
lastChecked = this;<br>
});
AD:真正免费,域名+虚机+企业邮箱=0元

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools