I want to hide some table td when I resize window or screen size is small.
I tried CSS media queries
th:nth-last-child(-n+7) {display:none}
td:nth-last-child(-n+7) {display:none}
th:last-child {display:none}
td:last-child {display:none}
It works but CSS cannot count td, so if a table has only three td then above code hide all three td.
Please help me achieve this using jQuery :
hide td on resize or screen size is small,
-
if screen width is 768px then show only six
tdand hide other from
right side -
if screen width is 480px then show only four
tdand hide other from
right side -
if screen width is 320px then show only three
tdand hide other
from right side
Use
:last-childandmax-widthmedia queries instead.td:nth-child(n+7)will only affect cells starting with the seventh cell in a row,td:nth-child(n+5)will only affect cells starting with the fifth cell in a row, and so on.http://jsfiddle.net/mblase75/GsxPK/