jQuery not:() - combing function
I've just written the following function and although it works - as in row colours are applied to all tables except those with the class .noAlternatingRows, due to .net not being able to apply a class directly to a table (no idea why - i'm not a .net developer, it's jut what i have b开发者_JAVA百科een told) - i now need to remove table styling from tables that are nested within a span.
This works, however is there a way of combining the two together? I've tried to comma separate the elements which i do not want the styling applied to, but it doesn't seem to work...
$("table:not(.noAlternatingRows, span table) tr:odd").css("background-color", "#d9d9d9");
$("table:not(.noAlternatingRows, span table) tr:even").css("background-color", "#f2f2f2");
$("span table tr:even").css("background", "none");
$("span table tr:odd").css("background", "none");
I'm sure there's a neater way of writing it - thanks :)
i now need to remove table styling from tables that are nested within a span
$('span tr').css("background", "none");
that's all folks ^^
Instead of this selector:
$("table:not(.noAlternatingRows, span table) tr:odd")
Try this one:
$("table:not(.noAlternatingRows, span > table) tr:odd")
This will only select tables that are directly nested in a span, instead of being nested at an arbitrary depth. If this doesn't work could you provide a jsFiddle with a (not) working testcase?
精彩评论