[JQUERY]checkBox的SHIFT快速多選功能

checkBox的SHIFT快速多選功能

<script>
//SHIFT快選功能
        var $chkboxes = $('.chk');
        var lastChecked = null;
        $chkboxes.click(function(e) {
            if (!lastChecked) {
                lastChecked = this;
                return;
            }

            if (e.shiftKey) {
                var start = $chkboxes.index(this);
                var end = $chkboxes.index(lastChecked);

                $chkboxes.slice(Math.min(start, end) + 1, Math.max(start, end)).click()
                
            }

            lastChecked = this;
        });
</script>