Posted By

kcmr on 07/12/08


Tagged

javascript DOM


Versions (?)


Advertising

Website Promotion DIRECTORY is a crucial factor for all websites that need to gain better organic search engine rankings and increase website traffic.
Submitting your website as part of your Web Promotion strategy to our SEO friendly and high traffic Business Directory for review is an excellent way to gain a valuable backlink and increase your websites visibility online.

Submit Site


Who likes this?

2 people have marked this snippet as a favorite

kcmr
SpinZ


getElementsByAttr


Published in: JavaScript 






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

Expand | Embed | Plain Text
  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 

You need to login to post a comment.