File tree Expand file tree Collapse file tree 1 file changed +32
-1
lines changed
10 - Hold Shift and Check Checkboxes Expand file tree Collapse file tree 1 file changed +32
-1
lines changed Original file line number Diff line number Diff line change 99
1010 html {
1111 font-family : sans-serif;
12- background : # ffc600 ;
12+ // background:#ffc600;
1313 }
1414
1515 .inbox {
9999 </ div >
100100
101101< script >
102+ // Check if they had the shift key down
103+ // AND check that they are checking it
104+
105+ const checkboxes = document . querySelectorAll ( '.inbox input[type="checkbox"' ) ;
106+ let lastChecked ;
107+
108+
109+ function checkedInput ( e ) {
110+ let inBetween = false ;
111+ if ( e . shiftKey && this . checked ) {
112+ //console.log('this has been checked');
113+ checkboxes . forEach ( checkbox => {
114+ console . log ( checkbox ) ;
115+ if ( checkbox === this || checkbox === lastChecked ) {
116+ inBetween = ! inBetween ;
117+ console . log ( 'this is last' ) ;
118+ }
119+ if ( inBetween ) {
120+ checkbox . checked = true ;
121+ }
122+
123+ } ) ;
124+ }
125+ lastChecked = this ;
126+ }
127+
128+ checkboxes . forEach ( function ( checkbox ) {
129+ checkbox . addEventListener ( 'click' , checkedInput ) ;
130+ } ) ;
131+
132+
102133</ script >
103134</ body >
104135</ html >
You can’t perform that action at this time.
0 commit comments