To elaborate, all browsers except IE allow you to alter the Element
prototype. This means we can add a method to Element and all elements
immediately have that method.

IE does not allow this, so whenever we get an element out of the DOM we have
to add those methods to that specific element reference. It's inefficient
and is one of the reason MooTools is a little slower in IE.

To add the methods to the element in IE, we pass it through any of the DOM
collection methods in MooTools including $/document.id, $$,
element.getElement, element.getElements, element.getParent,
element.getChildren, etc.

On Fri, Jan 15, 2010 at 8:13 AM, Ryan Florence <[email protected]> wrote:

> "The dollar function has a dual purpose: Getting the element by its id,
> and making an element in Internet Explorer "grab" all the 
> Element<http://mootools.net/docs/core/Element/Element#Element>
>  methods."
>
> - http://mootools.net/docs/core/Element/Element#dollar
>
> On Jan 15, 2010, at 8:15 AM, Slik Jay wrote:
>
> Maybe FF supports method getParent directly, IE have not this method.
> function $() creats it for IE
>
> On Fri, Jan 15, 2010 at 5:12 PM, silent <[email protected]> wrote:
>
> hi list,
>
>
> I found this piece of code works different in IE6 and firefox3.5:
>
>
>      function hook(el) {
>
> //        var sub_id = $('sub_id'); // use this will ok in two browsers
>
>          var sub_id = el; // if use this, next line will fail in IE6, but
>
> works in firefox3.5
>
>
>          var el2 = sub_id.getParent();
>
>          alert(el2);
>
>          return false;
>
>      };
>
> <input type="submit" id="sub_id" onclick="hook(this)" value="click"/>
>
>
> though at last I find out use "var sub_id = $(el)" also work,
>
> but could someone give me a describe on this problem ?
>
>
> thanks!
>
>
>
>

Reply via email to