Skip to content

Instantly share code, notes, and snippets.

@kazu69
Created February 5, 2012 09:06
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 kazu69/1744271 to your computer and use it in GitHub Desktop.
Save kazu69/1744271 to your computer and use it in GitHub Desktop.
checked true for iphone, ipad etc
var labelClick = function() {
var labels = document.getElementsByTagName('label');
console.log(labels);
for(var i=0,len=labels.length; i<len; i++){
if(labels[i].getAttribute('for')) {
labels[i].addEventListener('click',function(){
var id = this.getAttribute('for'),
target = document.getElementById(id);
if(['radio','checkbox'].indexOf(target.getAttribute('type')) !== -1){
target.setAttribute('checked',true);
}
else{
target.focus();
}
});
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment