1 parent cfc2cf0 commit bfe10afCopy full SHA for bfe10af
1 file changed
10 - Hold Shift and Check Checkboxes/index-START.html
@@ -104,6 +104,29 @@
104
</div>
105
106
<script>
107
+
108
+ const multipleCheck = document.querySelectorAll('.inbox input[type = "checkbox"]');
109
110
+ let lastChecked;
111
112
+ function handleCheck(e){
113
+ let inBetween = false;
114
+ if (e.shiftKey && this.checked){
115
+ multipleCheck.forEach(checkBox => {
116
+ // console.log(checkBox);
117
+ if (checkBox === this || checkBox === lastChecked){
118
+ inBetween = !inBetween;
119
+ // console.log('Finally checking it');
120
+ }
121
+ if (inBetween){
122
+ checkBox.checked = true;
123
124
+ })
125
126
+ lastChecked = this;
127
128
+ multipleCheck.forEach(checkBox => checkBox.addEventListener(`click`,handleCheck));
129
130
</script>
131
</body>
132
</html>
0 commit comments