Skip to content

Instantly share code, notes, and snippets.

@pdokas
Forked from anonymous/ipadlabels
Created October 27, 2010 16:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pdokas/649435 to your computer and use it in GitHub Desktop.
Save pdokas/649435 to your computer and use it in GitHub Desktop.
var iPadLabels = function () {
function fix() {
var labels = document.getElementsByTagName('label'),
label;
for (var i = 0; label = labels[i]; i++) {
if (label.getAttribute('for')) {
label.onclick = labelClick;
}
}
};
function labelClick() {
var el = document.getElementById(this.getAttribute('for'));
if (['radio', 'checkbox'].indexOf(el.getAttribute('type')) != -1) {
el.setAttribute('selected', !el.getAttribute('selected'));
} else {
el.focus();
}
};
return {
fix: fix
}
}();
@pdokas
Copy link
Author

pdokas commented Oct 27, 2010

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment