title: JavaScript dollar function, function $() error
body: <p>I've come across the dollar sign function over the internets and decided to use it for a javascript toggle menu. However, the "$" symbol makes my code fail.</p>
  
  <p>This is what I'm trying to use:</p>
  
  <pre><code>function $() {
          var elements = new Array();
          for (var i = 0; i &lt; arguments.length; i++) {
              var element = arguments[i];
              if (typeof element == 'string')
                  element = document.getElementById(element);
              if (arguments.length == 1)
                  return element;
              elements.push(element);
          }
          return elements;
      }
  
      function toggle(obj) {
          var el = $(obj);
          el.style.display = (el.style.display != 'none' ? 'none' : '' );
      }
  </code></pre>
  
  <p>The $ from "function $(){" seems to break the code. How do you declare this function?
  If I replace $ with "anything", it works, but not as a dollar function...</p>