I want to show / hide a column of a table using javascript / jquery .
Pressing a button shows or hides the entire column.
The name of the column is on TH identified by an id
I have achieved this by adding a class to each TD but I do not like this solution, I would like to achieve it without adding so much class attribute.
______ azszpr135702 ___
Without so much code can be fixed by putting 1 button, instead of 2.
Unless it's strictly necessary, I think it's better if you only have one button, that you make %code% that commutes the visibility of the column.
To do this, we select the header with %code% and hide it or show it with %code% .
To hide / show the rows, we can make a small filter like this:
%pre%
which means: Take the %code% that are your father's third child. The parent is the row %code% and the third child is the %code% in the Country column.
and to them you apply the %code% as well.
With this you save putting the %code% to each element you want to hide.
______ azszpr135706 ___
To hide with %code% , without Jquery, it occurs to me that since you already have a class that identifies you, you can use them to add a class %code% , for example.
If you also take into account the modification of %code% , you could delete the classes of each %code% and only add a %code% to the table as well as remove a button and have only %code% that works as a %code% , but all only with only %code%
______ azszpr135708 ___
You can also do the following from CSS:
%pre%
Or have a class hide in CSS and by means of javascript, add the class:
%pre%
___