-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjavascript.js
More file actions
21 lines (19 loc) · 770 Bytes
/
javascript.js
File metadata and controls
21 lines (19 loc) · 770 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// This function binds the event keycode 32 (space bar) to run the function toggleState
// This is needed since the default functionality of a check box is triggered with the space bar
function ARIA_Checkbox_Key(event) {
if(event.keyCode == 32){
toggleState(event.target)
}
}
// This function gets the aria-checked attribute of an element. If it is false, it makes it true and vice versa.
function toggleState(el) {
var img = el.getElementsByTagName('img')[0],
getvalue = el.getAttribute("aria-checked");
if (getvalue == "false") {
el.setAttribute("aria-checked", "true");
img.setAttribute("src", "checked.png");
} else {
el.setAttribute("aria-checked", "false");
img.setAttribute("src", "unchecked.png");
}
}