학습일자
2020.10.08
학습내용
- 이메일이나 게시물을 shift key 누른 상태에서 클릭하면 범위 설정해서 자동으로 check 할 수 있도록 하는 내용
알게된 점
- 이벤트 객체 내에 shiftKey 속성이 있음(true/false)
- this.checked로 접근하는 이유는 console.dir(this)로 확인해보면, checked 속성이 있음(true or false)
- 이해가 안됨 (lastChecked의 역할이 무엇?)
function handleCheck(e) {
let inBetween = false;
if (e.shiftKey && this.checked) {
checkboxes.forEach((checkbox) => {
if (checkbox === this || checkbox === lastChecked) {
inBetween = !inBetween;
console.log("Starting to check them in between!");
}
if (inBetween) {checkbox.checked = true;}
});
}
lastChecked = this;
}
'언어별 학습 자료 > Javascript' 카테고리의 다른 글
"# JavaScript 30" 강의 - 12. Key Sequence Detection (0) | 2020.10.20 |
---|---|
"# JavaScript 30" 강의 - 11. Custom Video Player (0) | 2020.10.16 |
"# JavaScript 30" 강의 - 09. Dev Tools Domination (0) | 2020.10.08 |
"# JavaScript 30" 강의 - 08. Fun with HTML5 Canvas (0) | 2020.10.08 |
"# JavaScript 30" 강의 - 04. Array Cardio Day 1 (0) | 2020.09.29 |