The Prototype Dollar Function


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

It doesn't require prototype.js


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.