
Originally Posted by
Twey
It's possible to use multiple classes seperated by spaces. However, I'm not sure how some browsers might react to this.
Any modern browser should handle it fine. IE 4 and NN 4 will ignore all classes specified in this way, but most CSS needs to be hidden entirely from these two anyway due to their woeful support.
My best suggestion is to use an id instead of a class for the sorting script.
But if there was more than one sortable table?
To the OP: Clearly, you can't use an equality operator to test if the table is to be sortable if it can contain more than one class name. Instead, you should use a regular expression. For example:
Code:
function ofClass(element, className) {
return (new RegExp('(^|\\s+)' + className + '(\\s+|$)')).test(element.className);
}
if(ofClass(myTable, 'sortable')) {
/* ... */
}
where myTable is a reference to the table element (obtained via the document.getElementById method, perhaps).
Mike
Bookmarks