Sam wrote:
> I'm confused about whether .addClass operates on a jQuery object as
> documented in jQuery.com/api/, and is listed as "Traversing" in the
> cheat sheet. Seems to me .addClass operates on the DOM, and is a
> "Manipulation" method?
Technically it's listed as
jQuery addClass( String class )
which means it takes as its argument a string and returns a jQuery
Object. While it does add classes to the elements referenced in the
jQuery Object it specifically returns the same jQuery Object to allow
chaining methods (ie
$('p').addClass('paragraph').addClass('happy').hide();) which is
jQuery's bread and butter.
Sam wrote:
> .eq(Number pos) and .get(Number num) appear nearly the same. From
> jquery.com/api/
.eq modifies the list of elements referenced in the jQuery Object to
one, and .get returns the actual element specified. This means that .eq
doesn't break the jQuery chain allowing you to do jQuery stuff with it
(ie $('p').eq(3).addClass('sad').removeClass('happy');) and .get returns
the actual original unmodified DOM Element allowing you to access those
raw properties therein (ie ('p').get(3).className = "panda";) but breaks
the jQuery chain.
Sam wrote:
> The documents suggests .eq() operates on a jQuery object, .get()
> operates on an Element, but the examples are the same.
If the docs show that same things happening to both, then either the
docs are incorrect (or I'm incorrect it's been known to happen :) or
this is a serendipitous event where there is a DOM method and a jQuery
method which are identical.
Hope this was helpful (and accurate).
-blair
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/