Here is the code snippet:
function getElementByClassName(strClassName) {
var eleNames = new Array();
var totalFrms = document.forms.length;
for(var i = 0; i < totalFrms; i++) {
//alert(document.forms[i].elements.length);
var eleLen = document.forms[i].elements.length;
for(var j = 0; j < eleLen; j++) {
if(strClassName === document.forms[i].elements[j].className) {
eleNames.push(document.forms[i].elements[j]);
}
}
}
return eleNames;
/*
for(t = 0; t < eleNames.length; t++) {
alert(eleNames[t].type);
}
*/
}
getElementByClassName("user_text");
Thats is. Hope this helps someone.
No comments:
Post a Comment