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

document.getElementById shortcut?

Expand Messages
  • Stuart Grimshaw
    I ve been using YUI for quite a while now, and over the weekend I was working with Prototype, I have no idea why it didn t jump out at me earlier, but does YUI
    Message 1 of 4 , May 31, 2007
    • 0 Attachment
      I've been using YUI for quite a while now, and over the weekend I was
      working with Prototype, I have no idea why it didn't jump out at me
      earlier, but does YUI provide anything similar to Prototype's $()
      shortcut to document.getElementById (and the others too)

      It's a bit of a tricky think to search for in the archive because the
      search function on the Yahoo Groups site doesn't treat $() as a keyword.

      -S
    • Gopalarathnam Venkatesan
      ... YAHOO.util.Dom.get() is YUI s getElementById (equivalent). If you want it similar to Prototype, you can use it like: var $ = YAHOO.util.Dom; and then use
      Message 2 of 4 , May 31, 2007
      • 0 Attachment
        Stuart Grimshaw wrote:
        >
        >
        > I've been using YUI for quite a while now, and over the weekend I was
        > working with Prototype, I have no idea why it didn't jump out at me
        > earlier, but does YUI provide anything similar to Prototype's $()
        > shortcut to document.getElementById (and the others too)
        >
        > It's a bit of a tricky think to search for in the archive because the
        > search function on the Yahoo Groups site doesn't treat $() as a keyword.
        >

        YAHOO.util.Dom.get() is YUI's getElementById (equivalent).

        If you want it similar to Prototype, you can use it like:

        var $ = YAHOO.util.Dom;

        and then use $().

        HTH.

        --
        Gopal Venkatesan

        http://gopalarathnam.com/
      • Stuart Grimshaw
        ... I had to use var $ = YAHOO.util.Dom.get; but other than that it works a treat, thanks very much.
        Message 3 of 4 , May 31, 2007
        • 0 Attachment
          > If you want it similar to Prototype, you can use it like:
          >
          > var $ = YAHOO.util.Dom;
          >
          > and then use $().

          I had to use

          var $ = YAHOO.util.Dom.get;

          but other than that it works a treat, thanks very much.
        • Gopalarathnam Venkatesan
          ... Oops! yes, sorry for the typo :D -- Gopal Venkatesan http://gopalarathnam.com/
          Message 4 of 4 , May 31, 2007
          • 0 Attachment
            Stuart Grimshaw wrote:
            >
            >
            >
            > > If you want it similar to Prototype, you can use it like:
            > >
            > > var $ = YAHOO.util.Dom;
            > >
            > > and then use $().
            >
            > I had to use
            >
            > var $ = YAHOO.util.Dom.get;
            >

            Oops! yes, sorry for the typo :D

            --
            Gopal Venkatesan

            http://gopalarathnam.com/
          Your message has been successfully submitted and would be delivered to recipients shortly.