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

replacement for getElementByID

Expand Messages
  • Nick Fox
    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 =
    Message 1 of 2 , Aug 1, 2008
    • 0 Attachment
      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
    • y_lsmith
      ... 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
      Message 2 of 2 , Aug 1, 2008
      • 0 Attachment
        --- 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
      Your message has been successfully submitted and would be delivered to recipients shortly.