Revision: 7183
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 12, 2008 08:06 by kcmr
Initial Code
function getElementsByAttr(tag, attr, value){ var arrayEl = new Array(); var el = document.getElementsByTagName(tag); for(i=0, j=0; i<el.length; i++){ if(el[i].getAttribute(attr) == value){ arrayEl[j] = el[i]; j++; } } return arrayEl; }
Initial URL
Initial Description
Use sample: var inputTxt = getElementsByAttr('input', 'type', 'text');
Initial Title
getElementsByAttr
Initial Tags
javascript, DOM
Initial Language
JavaScript