Sign In/My Account | View Cart  
advertisement

Article:
 jQuery and XML
Subject: $(this).get(0)
Date: 2007-10-16 11:39:24
From: aristotle

There is no point to saying $(this).get(0). It’s just a longer way to say this. $(this).get(0).namespaceURI should be written this.namespaceURI instead, f.ex.

Previous Message Previous Message   Next Message Next Message


Titles Only Titles Only Newest First
  • $(this).get(0)
    2007-10-16 13:01:12 Uche Ogbuji

    That's not correct, at least with jQuery 1.2.1 on FF 2. this.namespaceURI will give you an attribute error, because this is not a DOM node. It's a jQuery wrapper. The get method unwraps it.


    And yes, I tested both ways for the article.


    • $(this).get(0)
      2007-10-19 17:06:07 aristotle

      Ah. Well, if this is a jQuery object, then this.get(0) should work as well.


      The docs explicitly say about each (http://docs.jquery.com/Core/each) that “every time the passed-in function is executed (which is once for every element matched) the this keyword points to the specific DOM element” though, and it has in practice behaved that way for me. Very odd that you get different behaviour. *headscratch*


Sponsored By: