Posted By


kcmr on 07/12/08

Tagged


Statistics


Viewed 693 times
Favorited by 1 user(s)

getElementsByAttr


/ Published in: JavaScript
Save to your folder(s)

Use sample:
var inputTxt = getElementsByAttr('input', 'type', 'text');


Copy this code and paste it in your HTML
  1. function getElementsByAttr(tag, attr, value){
  2. var arrayEl = new Array();
  3. var el = document.getElementsByTagName(tag);
  4. for(i=0, j=0; i<el.length; i++){
  5. if(el[i].getAttribute(attr) == value){
  6. arrayEl[j] = el[i];
  7. j++;
  8. }
  9. }
  10. return arrayEl;
  11. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.