Its because the table in the original post is loaded with the ajax option. So the loading of the data is async. The code to add a class is running before the data is loaded (and thus any table cells drawn)!