I have a table structure (Table1) with thead and tbody.
My main thead also has a table inside with its own thead and tbody.
When I use $('#Table1 tbody')
it returns all tbody elements whereas I'd only need the tbody of the Table1.
How could this be achieved?
Thanks,
Within the required parent <table> element, the <tbody> element can be added after a <caption> , <colgroup> , and a <thead> element.
You could also have table > thead > tr and then table > tbody > tr. So you might need to specify whether you want the first row from the thead or the tbody. find('tr:first') will select the tr in the thead.
The <tbody> tag is used to group the body content in an HTML table. The <tbody> element is used in conjunction with the <thead> and <tfoot> elements to specify each part of a table (body, header, footer). Browsers can use these elements to enable scrolling of the table body independently of the header and footer.
Quoting the HTML 4 spec: "The TBODY start tag is always required except when the table contains only one table body and no table head or foot sections. The TBODY end tag may always be safely omitted."
$('#Table1 > tbody')
>
will get direct children.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With