Posted By

noname on 01/04/07


Tagged

prototype dollar


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

noname
vali29
hans


The Prototype Dollar Function


 / Published in: JavaScript
 

It doesn't require prototype.js

  1. function $() {
  2. var elements = new Array();
  3. for (var i = 0; i < arguments.length; i++) {
  4. var element = arguments[i];
  5. if (typeof element == 'string')
  6. element = document.getElementById(element);
  7. if (arguments.length == 1)
  8. return element;
  9. elements.push(element);
  10. }
  11. return elements;
  12. }

Report this snippet  

You need to login to post a comment.