Advanced Selector Building
I'm really impressed with selectors but I'm looking for some help with a specific setup.
Here's the sample HTML
-
<table>
<tr>
<td>Header Text</td>
<tr>
<td>data</td>
<td>data</td>
</tr>
repeats the above rows a few times
<tr>
<td class="KnownClass" colspan="2"></td>
</tr>
<tr>
<td colspan="2">
<a href="someurl">link 1</a>
<a href="someurl2">link 2</a>
</td>
</table>
I need to use jQuery to add CssClasses to the two href links at the bottom. I managed to get it to work using the script below but it's not exactly pleasing to the eyes.
-
$("tr td. KnownClass").parent().next().children().children().addClass("ui-state-default ui-corner-all").attr("style", "padding: 0px 6px 0px 6px;");
Is there a way to do this with out chaining so many methods?
Also can you guys help me understand the difference between
-
ancestor descendant
parent > child
Why isn't there a selector for the reverse? Selecting the parent elements that have a children with certain criteria?