Something like this (if you already have a lot of class checking, get an implementation of getElementsByClassName that accepts native implementations).
Code:
onload = function () { // Presumes no other onloads
var els = document.getElementsByTagName("input"), el;
for (var i = 0; i < els.length; i++) {
el = els[i];
if (el.className == "formInput") {
el.onfocus = function () {
// Whatever
};
el.onblur = function () {
// Whatever
};
}
els = document.getElementsByTagName("textarea");
for (i = 0; i < els.length; i++) {
el = els[i];
if (el.className == "formInput") {
el.onfocus = function () {
// Whatever
};
el.onblur = function () {
// Whatever
};
}
}
Bookmarks