Carl -- Javascript is case-sensitive, so you have to use hasClass rather
than hasclass each time you call it.
-- Josh
----- Original Message -----
From: "Carl Von Stetten" <[EMAIL PROTECTED]>
To: <jquery-en@googlegroups.com>
Sent: Wednesday, April 16, 2008 5:38 PM
Subject: [jQuery] Problem with using hasClass() within .each()
Using jQuery 1.2.3
Firefox 2.0.0.14
I am trying to loop through the headers of a tablesorter table and find
out which columns are being sorted which way. I'm building an array of
arrays that can be fed into the tablesorter.trigger function to resort
the table after changes are made to the DOM.
The problem I'm having is after .each() iterates successfully through
the first two columns (which currently are sorted) it then crashes on
.hasClass(). When I say crashes, I mean that Firebug reports the
following at the Console:
"$(this).hasclass is not a function"
Here is a snippet of my code. The id of the table in question is
"rdlist".
var columnsort = new Array();
parent.$("#rdlist th").each(function(idx){
var curhead = new Array();
if($(this).hasClass("headerSortDown")){
curhead.push(idx);
curhead.push(0);
}
else if($(this).hasclass("headerSortUp")){
curhead.push(idx);
curhead.push(1);
}
if(curhead.length)columnsort.push(curhead);
console.log(columnsort);
});
What am I doing wrong? :-(