Published in: JavaScript
Use sample: var inputTxt = getElementsByAttr('input', 'type', 'text');
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; }
You need to login to post a comment.
