3 ms·
He is claiming that the value "css" is special, along with a few others, in that when you call attr with it jQuery actually dispatches to the css method passing
by stanleydrew 16y ago
He is claiming that the value "css" is special, along with a few others, in that when you call attr with it jQuery actually dispatches to the css method passing the second argument as the value. He claims in the comments that this works with 1.4 (http://answers.oreilly.com/topic/2353-5-things-you-might-not-know-about-jquery#post_id_4373 http://answers.oreilly.com/topic/2353-5-things-you-might-not...), but I can't find it documented anywhere in jQuery's docs, nor can I make it work with the version of jQuery served on the jQuery docs site itself.
- pak 16y agoIIRC from the last time I browsed through jQuery source, attr('css', ...) is used internally but didn't look like it was meant to be exposed as a public method. And I never remember seeing this sort of special case in the docs. So, I wouldn't recommend using it in kosher jQuery code. A lot of things in this article seem a little dated; almost every tutorial now covers the $(function() {}) shortcut, and event binding is something I wouldn't know about jQuery? Really. Note to jeresig: this article illustrates a beef I remember passing on when the jQuery docs reorganized; it works well as API reference now, but before, introductory text for each section of the docs describing things like event namespacing made for a nicer introduction to beginners like me, as well as the structured sub-organization of methods within each section. Now, it's more of an alphabetical method soup, so a lot of beginners probably never bother to learn that event namespaces exist, or what the jQuery event object does. For example, you can only get to the documentation on the event object from within the documentation for methods like .bind(), which I find odd. (How would a beginner know that it even existed unless they went specifically to the .bind() docs in an alphabetical list of other cooler sounding methods?)