Generally the jQ object has methods that

  - can apply to the entire selected array of elements. Some extra
  methods are included for completeness - e.g. attr("href","#") sets the
  href attribute on all selected elements, but attr("href") will return the
  href value of the first selected element.
  - extend the DOM object functionality (e.g. all the traversal methods
  - find, parents, siblings, filter), are really convenient (e.g. hide -
  basically just sets style.display="hidden" on a bunch of elements), or
  encapsulate complex code in a simple method (e.g. load - uses ajax to
  load a web page and puts it in the selected elements)

As Matt said, DOM by itself is a lot faster, so if you don't need the extra
jQ stuff it's better to not use it.

Blair

On 12/13/06, Robert James <[EMAIL PROTECTED]> wrote:

I see.  Thanks for the clarification.

As a newcomer, I will say that this should be shown in the
docs/examples.  I had to undergo a lot of trial, error, and head
scratching before I figured this out.  (I don't think any of the docs
for $().each() show this).

BTW, what things do you need the DOM ,Object for, that you can't use
the JQ Object?  Why?


On 12/12/06, Christof Donat <[EMAIL PROTECTED]> wrote:
> Hi,
>
> > Why do I need to wrap the this with $(this) - (when using
$('#...').each) -
> > why isnt' that done automatically?
>
> Most of the time you use each(), because you want to access the DOM
Objects.
> That is exactly what you get as this. In most cases you need a jQuery
Object
> you can do your work outside of each().
>
> Christof
>
> _______________________________________________
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
>

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to