I have a page which is generating html tables dynamically. I do not have any control as to how the tables are being generated but I can put JavaScript code in it.
What I am trying to do is that there are some tables which are empty i.e. they have only row and no rows. I want to hide / remove those tables using JavaScript.
All the tables have a class "card-table".
Is it possible to find all the tables with "card-table" class and if has less than 1 row then remove/hide it?
Any help is appreciated.
Thanks in advance.
I’m just trying using jQuery or JavaScript but I’m not sure how to traverse the tables using same class and remove / hide them.
3
Answers
You can do something like this in jQuery
Not showing tables with zero rows
Vanilla
Tables have a built-in API for accessing and counting rows and columns. Use it: