Reputation: 1
I am working on a web application, and i have a couple of tables that are inside a main Div with ID = ctl00_PlaceHolderLeftNavBar_ctl02_WebTreeView
. now the main Div have many inner tables and one inner Div. so i need to do the following:-
tl00_PlaceHolderLeftNavBar_ctl02_WebTreeViewn10Nodes
.Here is the markup observed using firefox bug :-
now i have accomplished what i need by doing the following :-
#ctl00_PlaceHolderLeftNavBar_ctl02_WebTreeView > table:not(:nth-child(11)) {
display: none;
}
but this is not very elegant , because if i re-order the folders or add a new folder i need to chnage the nth-child(11)
. while defining it to hide all the tables except the one that comes before the inner div is more reliable ...
Can anyone advice on this? i am using jquery 1.10.2
Upvotes: 0
Views: 72
Reputation: 139
Below code is working for you
Upvotes: 0
Reputation: 58452
var wrapper = $('#ctl00_PlaceHolderLeftNavBar_ctl02_WebTreeView'),
tables = wrapper.children('table');
tables.not(wrapper.children('div').prev()).hide()
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="ctl00_PlaceHolderLeftNavBar_ctl02_WebTreeView">
<table><tr><td>hide</td></tr></table>
<table><tr><td>hide</td></tr></table>
<table><tr><td>hide</td></tr></table>
<table><tr><td>hide</td></tr></table>
<table><tr><td>show</td></tr></table>
<div id="tl00_PlaceHolderLeftNavBar_ctl02_WebTreeViewn10Nodes"></div>
<table><tr><td>hide</td></tr></table>
<table><tr><td>hide</td></tr></table>
</div>
try this:
Upvotes: 1
Reputation: 304
Use this thing.
$("#ctl00_PlaceHolderLeftNavBar_ctl02_WebTreeView").nextAll('table').css('display','none');
$("#tl00_PlaceHolderLeftNavBar_ctl02_WebTreeViewn10Nodes").prev('table').css('display','block');
Upvotes: 0