/ Published in: JavaScript

Clickable Form Labels for Safari and IE - prototype version
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function fixFormLabels(){ var labels; // enable for IE and Safari if( document.all || navigator.userAgent.indexOf("Safari") > 0){ labels = document.getElementsByTagName("label"); $A(labels).each ( function(label){ Event.observe(label, "click", function(){ var target = $(this.getAttribute('for')); // Checkboxes or radio button labels if(target.type == 'checkbox' || target.type == 'radio') target.checked = target.checked == false ? true : false; else // Textareas and input fields, Select elements target.focus(); }); }); } } // execute the script when the page has loaded Event.observe(window,"load", fixFormLabels);
Comments
