Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 53bb0a9

Browse files
committed
adding script wesbos#10
1 parent 05b35f4 commit 53bb0a9

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

10 - Hold Shift and Check Checkboxes/index-START.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,25 @@
9999
</div>
100100

101101
<script>
102+
const boxes = document.querySelectorAll('input');
103+
let inBetween = false;
104+
let lastChecked
105+
106+
function selectBox(e) {
107+
if(e.shiftKey && this.checked) {
108+
boxes.forEach(box => {
109+
if(box === this || box === lastChecked) {
110+
inBetween = !inBetween;
111+
}
112+
if(inBetween) {
113+
box.setAttribute('checked','true');
114+
}
115+
});
116+
}
117+
lastChecked = this;
118+
};
119+
120+
boxes.forEach(box => box.addEventListener('click',selectBox));
102121
</script>
103122
</body>
104123
</html>

0 commit comments

Comments
 (0)