[jQuery] When to Use'.' When Referring To Css Classes In JQuery

2009-11-03 Thread Mark Phillips
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: [jQuery] When to Use'.' When Referring To Css Classes In JQuery

2009-11-03 Thread Michel Belleville
. 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 mgphilli...@gmail.com

 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: [jQuery] When to Use'.' When Referring To Css Classes In JQuery

2009-11-03 Thread Karl Swedberg

Hi 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
www.englishrules.com
www.learningjquery.com




On Nov 3, 2009, at 8:06 AM, Mark Phillips 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.