Javascript hide column in table

Show Hide Table Column Using JavaScript

In this tutorial we will show you how to show hide table column using JavaScript.When user check or uncheck the checkbox a table column will hide or show respectively.You may also like sort table using jQuery.

Show Hide Table Column Using JavaScript

To Show Hide Table Column It Takes Only Two Steps:-

Step 1. Make a HTML file and define markup and scripting

We make a HTML file and save it with a name table.html

In this step we create a table and add some sample data for further working and create 3 checkbox one for each type of table column to hide and show the respective table column.

We create a function called ‘hide_show_table()’ to hide and show table column in this function we get the value of checkbox when clicked and check if the value is ‘hide’ it means we have to hide that particular table header and column and change that checkbox value to ‘show’ to show the hidden table header and column on next time.

Step 2. Make a CSS file and define styling

We make a CSS file and save it with a name table_style.css

body < text-align:center; width:100%; margin:0 auto; padding:0px; font-family:helvetica; background-color:#FA8258; >#wrapper < text-align:center; margin:0 auto; padding:0px; width:995px; >#checkbox_div < width:375px; margin-left:309px; >#checkbox_div p < margin:5px; color:white; font-weight:bold; font-size:17px; >#checkbox_div li < color:white; display:inline-block; margin:5px; font-size:17px; font-weight:bold; >#checkbox_div input[type=»checkbox»] < width:20px; height:20px; >#employee_table < color:#FE642E; background-color:white; text-align:center; >#employee_table th < border:1px dashed #FE642E; >#employee_table td

Читайте также:  Вывод в терминал php

Thats all, this is how to show and hide table column using JavaScript and HTML. You can customize this code further as per your requirement. And please feel free to give comments on this tutorial.

Источник

Оцените статью