Reputation: 491
I have a table with some nested tables ( this is outputted but a dotnet control i cant do anything about )
What i want is to move all the rows that are a direct child but so far its not working as I thought it would.
I have a basic setup that just takes all the rows, also the ones from the nested tables, I commented out a few others I trued that did not give the desired results
what i want that it moves the complete rows, even if the row has a nested table and it dont count the rows in that table in the slice functionality
You can see my setup at jsfiddle
Any help would be appreciated
Upvotes: 1
Views: 2687
Reputation: 39879
I know my answer is a bit late and jQuery has evolved since, but there is now a better way to do it, just call children() ! :)
$('#tblPropertyDetail').children().appendTo(".one");
You can even add a selector to the children()
method.
Here's the doc about children() in jQuery..
Upvotes: 0
Reputation: 179096
$('#tableID > * > tr, #tableID > tr')
just remember that * because JavaScript the browser automatically adds tbody elements.
EDIT:
Corrected a mistake about the tbody elements being added automatically.
Upvotes: 1
Reputation: 630469
You can use :not()
in all cases, or the child selector (>
) if you know your markup conditions:
$('#tblPropertyDetail tr:not(tr tr)').slice(0, 40).appendTo(".one");
You can test it here. The alternative is:
$('#tblPropertyDetail > tr').slice(0, 40).appendTo(".one");
However, this may or may not work depending on your DOCTYPE, it depends if a <tbody>
element it added in there for you (e.g. inferred in XHTML). To be safe add the <tbody>
yourself and do this:
$('#tblPropertyDetail > tbody > tr').slice(0, 40).appendTo(".one");
Upvotes: 2