Skip to content

Instantly share code, notes, and snippets.

@kaleb
Created April 17, 2011 15:15
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 kaleb/924110 to your computer and use it in GitHub Desktop.
Save kaleb/924110 to your computer and use it in GitHub Desktop.
Detect and fix leaky labels for disabled inputs
var lbl = document.createElement('label'),
chk = document.createElement('input'),
proto, lblOnClick;
chk.type = 'checkbox';
chk.disabled = true;
lbl.appendElement(chk);
lbl.click();
if (chk.checked) {
// Labels need to be fixed
proto = Object.getPrototypeOf(lbl);
lblOnclick = function(){
if(this.for.disabled) {
// prevent click from happening
}
}
proto.setEventHandler('click', lblOnClick);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment