|
10 | 10 | //All 3 functions take in the HTML name attribute of a certain group of input elements & performs the action (select all, none, invert) ONLY ON THAT GROUP |
11 | 11 |
|
12 | 12 | //Select all items in a group when given the HTML name attribute of some input elements in a group |
13 | | - function selectAll(nameToInvert){ |
14 | | - var inputs=$("input[name='"+nameToInvert+"']"); //array of inputs with the "name" attribute matching "nameToInvert", the argument passed in |
| 13 | + function selectAll(nameGroupToToggle){ |
| 14 | + var inputs=$("input[name='"+nameGroupToToggle+"']"); //array of inputs with the "name" attribute matching "nameGroupToToggle", the argument passed in |
15 | 15 | $.each(inputs, function(index){ //iterate over each item in "inputs" array |
16 | 16 | var element=$(inputs[index]); //get HTML object of each input element in the array |
17 | 17 | element.prop("checked", true); //Adds the property to all inputs. Doesn't matter if it's already true, changes the value to true anyway (redundant but not harmful) |
18 | 18 | }); |
19 | 19 | } |
20 | 20 |
|
21 | 21 | //Same structure as "selectAll()" but it changes the "checked" property to "false" to unselect each item |
22 | | - function selectNone(nameToInvert){ |
23 | | - var inputs=$("input[name='"+nameToInvert+"']"); |
| 22 | + function selectNone(nameGroupToToggle){ |
| 23 | + var inputs=$("input[name='"+nameGroupToToggle+"']"); |
24 | 24 | $.each(inputs, function(index){ |
25 | 25 | var element=$(inputs[index]); |
26 | 26 | element.prop("checked", false); //deselect the item |
27 | 27 | }); |
28 | 28 | } |
29 | 29 |
|
30 | 30 | //iterate through an array of input elements & negate the "checked" property |
31 | | - function invert(nameToInvert){ |
32 | | - var inputs=$("input[name='"+nameToInvert+"']"); //array of inputs with the "name" attribute matching "nameToInvert", the argument passed in |
| 31 | + function invert(nameGroupToToggle){ |
| 32 | + var inputs=$("input[name='"+nameGroupToToggle+"']"); //array of inputs with the "name" attribute matching "nameGroupToToggle", the argument passed in |
33 | 33 | $.each(inputs, function(index){ //iterate over each item in "inputs" array |
34 | 34 | var element=$(inputs[index]); //get HTML object of each input element in the array |
35 | 35 |
|
|
0 commit comments