How do I hide the middle of a table using jQuery?

前端 未结 6 889
时光取名叫无心
时光取名叫无心 2020-12-23 12:28

I have a really long 3 column table. I would like to


    <         
6条回答
tags the "Table_Middle" class it makes it much easier to do. Then it only takes a few lines of jQuery. One to add the "Show Full Table" row, and another to add a click listener for that row. Make sure to change the colspan attribute's "X" value to the number of columns in your table.

 // jQuery chaining is useful here
 $(".Table_Middle").hide()
                   .eq(0)
                   .before('
Show Full Table'); $(".showFull").click(function() { $(this).toggle(); $(".Table_Middle").toggle(); });

This is useful because it degrades nicely and is accessible across lots of browsers/devices. If JavaScript is turned off, or CSS is disabled (or any other scenario that could cause this code to not be supported), there is no "show full table" row.

提交回复
热议问题
Column1Column2