Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is this function not replacing the class
    text
    copied!<p>I have a function that I'm testing, it is supposed to check all table headers to see if it has a particular class, remove it and replace it with another class. I'm using this to switch metadata parsers for the tablesorter plugin. The code I have so far is below:</p> <pre><code>$(function(){ $("th").each(function(){ if ($(this).hasClass("{sorter: 'usLongDate'}")) { $(this).removeClass("{sorter: 'usLongDate'}").addClass("{sorter: 'false'}"); } }); }); $(function() { $("table").tablesorter({}); }); </code></pre> <p>I'm trying to switch the class parser in the following header to the false inline parser.</p> <pre><code>&lt;th class="{sorter: 'usLongDate'}"&gt;&lt;a rel = "Header" href="#" title="Sort column in decending order" class=""&gt;Date&lt;/a&gt;&lt;/th&gt; </code></pre> <p>Of course this isn't my only header, I'm just testing it on this one, I'm assuming the rest of the headers shouldn't be affected, tablesorter should still be sorting those. But when I run the html file, nothing works. Is there something I'm missing?? Thanks.</p> <p>NOTE: Just to avoid confusion, the tablesorter plugin for jQuery can use inline parsers within the class attribute of a table header in order to determine how and/or whether a column should be sorted. </p> <p>UPDATE: Tried Vincent Robert's suggestion, unfortunately it doesn't work. In regards to whether or not addClass and removeClass can handle these. I have an original function that was able to add the disable parser to all classes, </p> <pre><code>$("th[class='']").addClass("{sorter: 'false'}"); </code></pre> <p>this comes from Paolo Bergantino, and it worked great. I'm just trying to extend it a bit.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload