I need to select the first TD of every table row where the following conditions are met:
- TD does not have colspan
- TD in the first table and not any of the nested ones
The following does not work for me…
$("table:first > td:first-child").not("[colspan]").css("background-color","red");
To limit to the
tds of the outer table, you can drill down to a specific level using multiple child selectors.Note that I included
tbody. You should explicitly include it in your table since most browsers (but not necessarily all) will inject it when missing.If you have
theadandtfootelements that should be included, use*instead oftbody.