I trying to understand jquery, and can’t figure a problem out. I have a page with 2 or more tables on there, but I want to be able to identity all tables which have a certain class (they may have more than 1 class). Once I have this table/tables, I want to update the class on the odd/even rows.
This works, but it sets the class on all tables, irrespective if they have the tableData class or not.
$(function() {
if($("table").hasClass("tableData")) {
$("tr:odd").addClass("alt");
};
});
This doesn’t work (nor other versions which I’ve tried).
$(function() {
if($("table").hasClass("tableData")) (function() {
$(this).("tr:odd").addClass("alt");
});
});
Thanks in advance.
This should do it: