Reputation: 1
I have the following code inside my SharePoint web page, it mainly contains a div and 5 tables inside it (the number of tables can be increased or decreased in the future).
So I want to hide all tables except the table that have its third TD tile within the first TR equals to "Pages"? Currently I wrote the following to hide all tables except the third table, but as the number of tables may change so this will break, so I want to make my CSS more dynamic , by using the title ?
#ctl00_PlaceHolderLeftNavBar_ctl02_WebTreeView > table:not(:nth-child(3)) {
display: none;
}
Can anyone advice?
Upvotes: 0
Views: 196
Reputation: 41968
This is not possible with CSS right now, because you want to select a specific element, the a
in this case, and then actually apply CSS rules to one of its parents. CSS can (right now) only apply rules to the actually selected element.
You need Javascript to fix this issue. In MooTools for example this would work:
$$('div.thatYouAreTargeting table').each(function(t) {
if(t.getElement('a[title=Pages]'))
t.setStyle('display', 'none');
});
With jQuery it's equally simple, with native Javascript a tad more verbose.
Upvotes: 1