明天想換個東西:可能想先瀏覽一下其他前端鐵人挑戰,學學 vue.js 等等。
this, checkboxes.checked
const checkboxes = document.querySelectorAll('input[type="checkbox"]');
let lastChecked ;
function handlecheck(e) {
let inBetween = false;
if (e.shiftKey && this.checked) {
checkboxes.forEach(checkbox => {
console.log(checkbox);
if (checkbox === this || checkbox === lastChecked) {
inBetween = !inBetween;
console.log('start to check inbetween');
}
if (inBetween ) {
checkbox.checked = true;
}
})
};
lastChecked = this;
}
checkboxes.forEach(checkbox => checkbox.addEventListener('click',handlecheck));