When to Use'.' When Referring To Css Classes In JQuery
|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
When to Use'.' When Referring To Css Classes In JQueryHi,
Is there some general rule to determine when '.' should be added to JQuery method parameters when referring to CSS classes. Here's an example from the excellent book "Learning JQuery 1.3" if ($header.is('.sort-alpha')) { findSortKey = function($cell) { return $cell.find('sort-key') .text().toUpperCase() + ' ' + $cell.text ().toUpperCase(); }; } In this case both '.sort-alpha' and 'sort-key' are CSS classes. How does one know when to include the '.' Thanks, Mark PS. I accidentally placed this in the JQuery Plugin Discussions. Apologies for the duplication. |
|
|
Re: When to Use'.' When Referring To Css Classes In JQuery"." should be used each time you're looking for a class using a search pattern. That's all. There may be a typo in the aforementionned excellent book.
Michel Belleville 2009/11/3 Mark Phillips <mgphillips1@...> Hi, |
|
|
Re: When to Use'.' When Referring To Css Classes In JQuery"." is what is used to say "find this class".... so the find('sort-
key') is simply a typo, as it's missing the needed period find(".sort-key") would get <span class="sort-key"> find("sort-key") would look for <sort-key> On Nov 3, 8:06 am, Mark Phillips <mgphilli...@...> wrote: > Hi, > > Is there some general rule to determine when '.' should be added to > JQuery method parameters when referring to CSS classes. Here's an > example from the excellent book "Learning JQuery 1.3" > > if ($header.is('.sort-alpha')) { > findSortKey = function($cell) { > return $cell.find('sort-key') > .text().toUpperCase() + ' ' + $cell.text > ().toUpperCase(); > }; > } > > In this case both '.sort-alpha' and 'sort-key' are CSS classes. How > does one know when to include the '.' > > Thanks, > Mark > > PS. I accidentally placed this in the JQuery Plugin Discussions. > Apologies for the duplication. |
|
|
Re: When to Use'.' When Referring To Css Classes In JQueryHi Mark,
I checked my pre-release PDF of the book as well as a print copy and haven't been able to locate the code that has return $cell.find('sort-key') without the "." for the sort-key class. If you wouldn't mind, could you point me to the page number where you saw that? I'll make sure it gets into the list of errata on the Packt website and at http://book.learningjquery.com/6705/errata.html thanks so much, --Karl ____________ Karl Swedberg On Nov 3, 2009, at 8:06 AM, Mark Phillips wrote:
|
| Free embeddable forum powered by Nabble | Forum Help |