Jquery dynamically inserts table nesting tables, no matter how to use the selector, node elements to get repetition, traversing repetition problems?

problem description: the data rendered by the foreground page is a table inserted by append, and another table is inserted in each row of td, which is equivalent to a nested table.

     ,;  ,,??...
     
The display of

data is normal, all tables are nested tables, printing is normal when there is only a single row of data; when there are multiple rows, it is confused; how do you solve the problem of data acquisition? Or there is a better data display assignment method, please let me know how to get it. Thank you.


specific append code

Jun.23,2021

if you want to post a code to ask a question, do you paste two lines of code here or do you lay the groundwork for the following phenomenon

use the jq selector to filter out three elements, then the page has three material elements instead of two, you can search under the page, and you only want to add two, but generate three, there must be something wrong with your code, specific where there is a problem, but also depends on how you add.

< hr > < H2 > add < / H2 >

selector error: $('- sharpaddgoods tr:last-child') is the last tr, under select-sharpaddgoods instead of the direct subset tr of-sharpaddgoods. This causes you to choose the tr of the table newly appended to td. Because of find Filter, when there are two data, the first traversal will only find a direct subset, but the second traversal will also find the appended td of the first traversal, so there is more this time. It's the same for 6 times.

modify: $('- sharpaddgoods tr:last-child') change to $('- sharpaddgoods > tr:last-child') . In addition, when adding table to td, there is a layer of tr, in the outer layer of th. Although the browser will automatically complete it for you, it is also a mistake.

Menu