This article describes the method of JavaScript controlling a table column not to be displayed. Share it for your reference. The specific implementation method is as follows:
1. Table code
Copy the code as follows:<table id="mytable" align="center"
cellpadding="3" cellpacing="1" bgcolor="#dfdfdf">
<tbody id="tbody1" style="background: #e4e9f0; font-weight: bold;">
<tr>
<td bgcolor="#FFFFFF">Date</td>
<td bgcolor="#FFFFFF">Media Name</td>
<td bgcolor="#FFFFFF">Putting Form</td>
<td bgcolor="#FFFFFF">Number of exposures</td>
<td bgcolor="#FFFFFF">Number of exposure</td>
<td bgcolor="#FFFFFF">Clicks</td>
<td bgcolor="#FFFFFF">Number of clicks</td>
<td bgcolor="#FFFFFF">CTR</td>
<td bgcolor="#FFFFFF">Visited</td>
<td bgcolor="#FFFFFF">Number of bounces</td>
<td bgcolor="#FFFFFF">Access Depth</td>
<td bgcolor="#FFFFFF">Browse time/second</td>
<td bgcolor="#FFFFFF">Number of participants</td>
<td bgcolor="#FFFFFF">Number of business handlers</td>
</tr>
</tbody>
<tbody id="detail_id"></tbody>
</table>
2. JS controls according to permissions
Note: If the data is dynamic data, the control display of td after the assignment is completed. Otherwise, the control of the td header will be successful and other rows will fail.
if (uname === "guest") { $("#mytable tr").each(function() { $(this).find("td").eq(7).css("display", "none"); $(this).find("td").eq(8).css("display", "none"); $(this).find("td").eq(9).css("display", "none"); $(this).find("td").eq(10).css("display", "none"); $(this).find("td").eq(11).css("display", "none"); $(this).find("td").eq(12).css("display", "none"); $(this).find("td").eq(13).css("display", "none"); });}I hope this article will be helpful to everyone's JavaScript programming.