【发布时间】:2015-05-16 11:41:21
【问题描述】:
我已经搜索了几个小时,但找不到像我一样创建的表,其中有隐藏/显示实例 - 我尝试使用标准 HTML 表的一些标准隐藏/显示,但它没有t 像我需要的那样翻译工作。
我在 JS 中创建了一个从 json 加载数据的表,如下所示:
var output = "<table class = sample>",
tableHeadings = "<thead>" +
//set column names
"<tr>" +
"<th></th>" +
"<th><u>Name:</u></th>" +
"<th><u>Address:</u></th>" +
"<th><u>City:</u></th>" +
"<th><u>State:</u></th>" +
"<th><u>Phone Number:</u></th>" +
"<th><u>PO:</u></th>" +
"<th><u>Stuff:</u></th>" +
"<th><u>Stuff:</u></th>" +
"<th><u>Stuff:</u></th>" +
"<th><u>Stuff:</u></th>" +
"<th><u>Stuff:</u></th>" +
"</tr>" +
"</thead>";
output += tableHeadings;
output += "<td>"+'<a href="#" onclick="javascript:displayInfobox(' + (i) + ');">' + results[i]["Business Name"] +'<\/a>' + "</td>" +
"<td>" + results[i]["Address"] + "</td>" +
"<td><center>" + results[i]["City"] + "</center></td>" +
"<td><center>" + results[i]["StateListing"] + "</center></td>";
document.getElementById("placeholder").innerHTML = output;
我想要做的是使用按钮/复选框隐藏/显示地址列。我尝试在 jquery 中使用 style.display 和 .hide/.show 。我尝试的所有操作都会隐藏第一个条目,但之后仍会显示每个条目的地址。
我需要能够在命令中隐藏所有显示的条目的地址信息。
【问题讨论】:
标签: javascript html-table show-hide