File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
10 - Hold Shift and Check Checkboxes Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 104104 </ div >
105105
106106< script >
107+ const checkboxes = document . querySelectorAll ( '.inbox input[type="checkbox"]' ) ;
108+
109+ let lastChecked ;
110+
111+ function handleCheck ( e ) {
112+ //Check if shift key was held
113+ //And make sure they're checking it
114+ let inBetween = false ;
115+ if ( e . shiftKey && this . checked ) {
116+ checkboxes . forEach ( checkbox => {
117+ console . log ( checkbox ) ;
118+ if ( checkbox === this || checkbox === lastChecked ) {
119+ inBetween = ! inBetween ;
120+ console . log ( 'Starting to check in between' ) ;
121+ }
122+ if ( inBetween ) {
123+ checkbox . checked = true ;
124+ }
125+ } ) ;
126+ }
127+ lastChecked = this ;
128+ // console.log(lastChecked);
129+ } ;
130+
131+ // console.log(checkboxes);
132+ checkboxes . forEach ( checkbox => checkbox . addEventListener ( 'click' , handleCheck ) ) ;
133+
107134</ script >
108135</ body >
109136</ html >
You can’t perform that action at this time.
0 commit comments