Now there is a table, each tr has a number as class. Assume that a tr is selected. How to get all tr whose class is less than or equal to the selected tr?
You should not use tr numbers as classes, because there are many classes bound to tr. You can completely bind numbers to data-num. The logic is probably as follows. Maybe some selectors are not written so accurately
You can only select in a loop. What is the size of the number?
You should not use tr numbers as classes, because there are many classes bound to tr. You can completely bind numbers to data-num. The logic is probably as follows. Maybe some selectors are not written so accurately
html table:
js:
What the first floor said is right. Generally, no one names a class with a number. They usually add a custom attribute
Traverse the values of all classes and then compare and store them. (ps: But using numbers as classes is not very standard.)
Sort by class, and then get all the tr before the target tr