Loading ...
Sorry, an error occurred while loading the content.

35386Re: replacement for getElementByID

Expand Messages
  • y_lsmith
    Aug 1, 2008
      --- In ydn-javascript@yahoogroups.com, "Nick Fox"
      <nicolaspatrickfox@...> wrote:
      >
      >
      > Is there a replacement in the library for getElementByID like in
      > prototype.js. What library is it in if there is?
      >
      > var a = $('b'); // prototype.js
      >
      > for
      >
      > var a = document.getElementByID('b');
      >
      > thanks
      > Nick
      >

      YAHOO.util.Dom.get('b');

      It's common to create an alias to YAHOO.util.Dom, or even to Dom.get
      to shave verbosity:

      // wrap in anon function to avoid poluting the global namespace
      (function () {

      var Dom = YAHOO.util.Dom;

      ...
      var b = Dom.get('b');
      ...

      })();

      Hope this helps,
      Luke
    • Show all 2 messages in this topic