jquery - Add css class to a td tag using javascript -
i'm trying make timetable moodle in form of greasemonkey script.
the idea highlight subject current hour, can't find working way of doing it.
i'm injecting css page, , using jquery add injected css class target td.
this css code injected page header:
.current_class {background-color:green};
and javascript code used add class td:
var cell = $("#timetable_table").find("tr").eq(current+1).find("td").eq(date.getday());
i know cell correct td because can cell.text("foo") , correct cell modified, when do:
cell.addclass("current_class");
the table stays same.
i don't have way, want dynamically change background on td tag, don't mind using other methods.
thanks.
first suggest change this:
var cell = document.getelementbyid('timetable_table').rows(current+1).cells(date.getday());
and:
cell.classname += (cell.classname ? " " : "")+"current_class";
but that's performance reasons
the probable cause of issue have background-color
being defined elsewhere greater specificity. try using css selector:
#timetable_table tr>td.current_class{background-color:green};
that should specific enough win.
Comments
Post a Comment