Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/311.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Jquery在HTML表中添加单元格我想我设置它显示无,因为这些是ID?MVC_Javascript_C#_Jquery_Html_Asp.net Mvc - Fatal编程技术网

Javascript Jquery在HTML表中添加单元格我想我设置它显示无,因为这些是ID?MVC

Javascript Jquery在HTML表中添加单元格我想我设置它显示无,因为这些是ID?MVC,javascript,c#,jquery,html,asp.net-mvc,Javascript,C#,Jquery,Html,Asp.net Mvc,我实际上是在向HTML表中添加id,而不是使用它们来保存。 但我不想表现出来 这是我的jquery,用于将单元格添加到表中 $("body").on("click", "#btnAdd", function () { //Reference the Name and Country TextBoxes. var txtName = $("#txtFamilyName"); // var txtCountry = $("#t

我实际上是在向HTML表中添加id,而不是使用它们来保存。 但我不想表现出来

这是我的jquery,用于将单元格添加到表中

 $("body").on("click", "#btnAdd", function () {
            //Reference the Name and Country TextBoxes.
            var txtName = $("#txtFamilyName");
            // var txtCountry = $("#txtCountry");

        //Get the reference of the Table's TBODY element.
        var tBody = $("#tblCustomers > TBODY")[0];

        //Add Row.
        var row = tBody.insertRow(-1);

        //Add Name cell.


        var cell = $(row.insertCell(-1));
        cell.html($('#ddlregion').find('option:selected').text());

        var cell = $(row.insertCell(-1));
        cell.html($('#ddlcityy').find('option:selected').text());

        var cell = $(row.insertCell(-1));
        cell.html(ddlcityy.value);

        var cell = $(row.insertCell(-1));
        cell.html(ddltribe.value);



 //Add Button cell.
            cell = $(row.insertCell(-1));
            var btnRemove = $("<input />");
            btnRemove.attr("type", "button");
            btnRemove.attr("onclick", "Remove(this);");
            btnRemove.val("Remove");
            cell.append(btnRemove);

        });
他们都在工作,但只为一个细胞

让我看看我换成什么

 var cell = $(row.insertCell(-1));
        cell.html(ddlcityy.value);
        cell.setAttribute("hidden", true);

        var cell = $(row.insertCell(-1));
        cell.html(ddltribe.value);
        cell.setAttribute("hidden", true);
“Cityid”是3,“Tribeid”是1,每次只隐藏部落id而不是城市id。 我甚至将它们的变量名从cell改为cell1,但结果是一样的


为什么只隐藏部落id?

只需通过设置为
none
来隐藏该行,就像
document.getElementById(yourCell.style.display='none'
添加后如何设置其style属性您的
cell
id是正确的吗?将单元格id
document.getElementById(yourCell.style.display==“none”
传递到
cell.html(ddlbreage.value)之后不,我没有在我的查询中添加这个
cell.setAttribute(“hidden”,true)或'cell.style.display='none'`只需通过设置为
none
来隐藏该行,就像
document.getElementById(yourCell.style.display==“none”
添加后如何设置其样式属性您有
cell
id权限?将单元格id
document.getElementById(yourCell.style.display==“none”
传递到
cell.html(ddlbreage.value)之后不,我没有在我的查询中添加这个
cell.setAttribute(“hidden”,true)或'cell.style.display='none'`
 var cell = $(row.insertCell(-1));
        cell.html(ddlcityy.value);
        cell.setAttribute("hidden", true);

        var cell = $(row.insertCell(-1));
        cell.html(ddltribe.value);
        cell.setAttribute("hidden", true);