- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在通过服务器端(C#)代码创建一些html元素。由于这是一个jQuery论坛,因此我不会显示该代码,但是会添加一个列标题行和可见的“文本框”的第一行;然后,我再添加两行以不可见的文本框。另外,我(没有双关语)有一个按钮(带有标题“ +”),该按钮应使第一次单击时可见的第一行不可见,而在第二次单击时可见的第二行不可见。我正在尝试使用此jQuery完成此操作:
$(document).on("click", '[id$=btnAddFoapalRow]', function (e) {
if ($('[id$=foapalrow3]').not(":visible")) {
console.log('reached the foapalrow3 not visible branch');
// $('[id$=foapalrow3]').slideDown(); <= neither this nor the below works
$('[id$=foapalrow3]').attr("visibility", "visible");
}
else if ($('[id$=foapalrow4]').not(":visible")) {
console.log('reached the foapalrow4 not visible branch');
$('[id$=foapalrow4]').slideDown();
}
});
foapalrow3 = new HtmlTableRow();
foapalrow3.ID = "foapalrow3";
var cellColIndex2 = new HtmlTableCell();
cellColIndex2.Width = CELL_WIDTH;
foapalrow3.Cells.Add(cellColIndex2);
var cellColFund2 = new HtmlTableCell();
cellColFund2.Width = CELL_WIDTH;
foapalrow3.Cells.Add(cellColFund2);
var cellColOrg2 = new HtmlTableCell();
cellColOrg2.Width = CELL_WIDTH;
foapalrow3.Cells.Add(cellColOrg2);
var cellColAccount2 = new HtmlTableCell();
cellColAccount2.Width = CELL_WIDTH;
foapalrow3.Cells.Add(cellColAccount2);
var cellColActivity2 = new HtmlTableCell();
cellColActivity2.Width = CELL_WIDTH;
foapalrow3.Cells.Add(cellColActivity2);
var cellColAmount2 = new HtmlTableCell();
cellColAmount2.Width = CELL_WIDTH;
foapalrow3.Cells.Add(cellColAmount2);
boxIndex2 = new TextBox()
{
CssClass = "dplatypus-webform-field-input",
Width = TEXTBOX_WIDTH
};
cellColIndex2.Controls.Add(boxIndex2);
boxFund2 = new TextBox()
{
CssClass = "dplatypus-webform-field-input",
Width = TEXTBOX_WIDTH
};
cellColFund2.Controls.Add(boxFund2);
boxOrganization2 = new TextBox()
{
CssClass = "dplatypus-webform-field-input",
Width = TEXTBOX_WIDTH
};
cellColOrg2.Controls.Add(boxOrganization2);
boxAccount2 = new TextBox()
{
CssClass = "dplatypus-webform-field-input",
Width = TEXTBOX_WIDTH
};
cellColAccount2.Controls.Add(boxAccount2);
boxActivity2 = new TextBox()
{
CssClass = "dplatypus-webform-field-input",
Width = TEXTBOX_WIDTH
};
cellColActivity2.Controls.Add(boxActivity2);
boxAmount2 = new TextBox()
{
CssClass = "dplatypus-webform-field-input",
Width = TEXTBOX_WIDTH
};
cellColAmount2.Controls.Add(boxAmount2);
foapalHTMLTable.Rows.Add(foapalrow3);
foapalrow3.Visible = false;
foapalrow3.Visible = false;
<h2>Section 5: FOAPAL / Payment Amount Information</h2></span><br></br><button id="ctl00_ctl24_g_5f3fedca_19f7_4bc3_b84e_efbef0c48a33_ctl00_btnAddFoapalRow" type="button" OnClientClick="return false;">+</button><table border="2">
<span class="finaff-webform-field-label" style="display:inline-block;">Explain Payment: </span><textarea name="ctl00$ctl24$g_5f3fedca_19f7_4bc3_b84e_efbef0c48a33$ctl00$explainPaymentTextBox" rows="2" cols="20" id="ctl00_ctl24_g_5f3fedca_19f7_4bc3_b84e_efbef0c48a33_ctl00_explainPaymentTextBox" class="finaff-webform-field-input" style="width:660px;display:inline-block;"></textarea><br></br><span class="finaff-webform-field-label"><h2>Section 5: FOAPAL / Payment Amount Information</h2></span><br></br><button id="ctl00_ctl24_g_5f3fedca_19f7_4bc3_b84e_efbef0c48a33_ctl00_btnAddFoapalRow" type="button" OnClientClick="return false;">+</button><table border="2">
<tr>
<td width="88px" style="text-align:center;"><span class="finaff-webform-field-label">Index</span></td>
<td width="88px" style="text-align:center;"><span class="finaff-webform-field-label" style="text-align:center;">Fund</span></td>
<td width="88px" style="text-align:center;"><span class="finaff-webform-field-label" style="text-align:center;">Organization</span></td>
<td width="88px" style="text-align:center;"><span class="finaff-webform-field-label" style="text-align:center;">Account</span></td>
<td width="88px" style="text-align:center;"><span class="finaff-webform-field-label" style="text-align:center;">Activity</span></td>
<td width="88px" style="text-align:center;"><span class="finaff-webform-field-label" style="text-align:center;">Amount</span></td>
</tr>
<tr>
<td width="88px"><input name="ctl00$ctl24$g_5f3fedca_19f7_4bc3_b84e_efbef0c48a33$ctl00$ctl130" type="text" class="finaff-webform-field-input" style="width:88px;" /></td>
<td width="88px"><input name="ctl00$ctl24$g_5f3fedca_19f7_4bc3_b84e_efbef0c48a33$ctl00$ctl132" type="text" class="finaff-webform-field-input" style="width:88px;" /></td>
<td width="88px"><input name="ctl00$ctl24$g_5f3fedca_19f7_4bc3_b84e_efbef0c48a33$ctl00$ctl134" type="text" class="finaff-webform-field-input" style="width:88px;" /></td>
<td width="88px"><input name="ctl00$ctl24$g_5f3fedca_19f7_4bc3_b84e_efbef0c48a33$ctl00$ctl136" type="text" class="finaff-webform-field-input" style="width:88px;" /></td>
<td width="88px"><input name="ctl00$ctl24$g_5f3fedca_19f7_4bc3_b84e_efbef0c48a33$ctl00$ctl138" type="text" class="finaff-webform-field-input" style="width:88px;" /></td>
<td width="88px"><input name="ctl00$ctl24$g_5f3fedca_19f7_4bc3_b84e_efbef0c48a33$ctl00$ctl140" type="text" class="finaff-webform-field-input" style="width:88px;" /></td>
</tr>
</table>
boxIndex2 = new TextBox()
{
CssClass = "finaff-webform-field-input",
Width = TEXTBOX_WIDTH,
ID = "boxIndex2foapalrow3"
};
cellColIndex2.Controls.Add(boxIndex2);
foapalrow3.Visible = false;
cellColAmount2.ID = "cellAmount2foapalrow3";
foapalrow3.Height = "0";
foapalrow3.Attributes.Add("display", "none");
foapalHTMLTable.Rows.Add(foapalrow3);
//foapalrow3.Visible = false;
$(document).on("click", '[id$=btnAddFoapalRow]', function (e) {
if ($('[id$=foapalrow3]').not(":visible")) {
console.log('reached the foapalrow3 not visible branch');
$('[id$=foapalrow3]').attr("display", "table-row");
}
else if ($('[id$=foapalrow4]').not(":visible")) {
console.log('reached the foapalrow4 not visible branch');
$('[id$=foapalrow4]').slideDown();
}
});
foapalrow3.Attributes["class"] = "hiddenTableRow";
foapalHTMLTable.Rows.Add(foapalrow3);
<style>
.hiddenTableRow {
display:none;
}
</style>
<script type="text/javascript">
/* This is supposed to make the rows visible, but is not yet working... */
$(document).on("click", '[id$=btnAddFoapalRow]', function (e) {
$("[id$=foapalrow3]").removeClass("hiddenTableRow");
if ($('[id$=foapalrow3]').not(":visible")) {
$('[id$=foapalrow3]').attr("display", "table-row");
}
else if ($('[id$=foapalrow4]').not(":visible")) {
console.log('reached the foapalrow4 not visible branch');
$('[id$=foapalrow4]').slideDown();
}
});
</script>
最佳答案
从服务器端代码中删除foapalrow3.Visible = false;
,因为这将防止为该行生成html
应用CSS属性display:none;
向foapalrow3添加类或样式
在您的按钮上单击,从foapalrow3中删除类,或者如果您选择使用样式属性,请将display
更改为display:table-row;
例如
的CSS
.hiddenTableRow {
display:none;
}
// foapalrow3.Visible = false;
// Edit - CssClass is not present on HtmlTableRow
// foapalrow3.CssClass = "hiddenTableRow";
foapalrow3.Attributes["class"] = "hiddenTableRow";
$("[Css Selector To find the Row]").removeClass("hiddenTableRow");
关于javascript - 如何使用jQuery来显示HtmlTableRow(开始隐藏/隐藏生命)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30986774/
我在客户端生成了一个 HTML 行 ( ),我想将包含行单元格信息的字符串转换为 HtmlTableRow控制。这就是我到目前为止使用 Convert string to WebControls -
我有一个 HtmlTable,默认情况下有两行,但可以使用以下代码“增长”到六行: /* This makes the next hidden row visible, as long as ther
我正在使用 HtmlUnit。 我有一个 HtmlTableRow 类型的对象,我想将所有内容转储到一个变量中,我该怎么做? 即只是想获得如下 HTML:.... 最佳答案 Here's the Ht
我正在将应用程序从 .NET 移植到 .NET Core,但找不到 HtmlTableRow 类的模拟 Error CS0246 The type or namespace name 'Html
我已在另外两个页面中成功使用了以下代码: ID Name Length #
我想创建一个在 ASCX 文件中包含以下内容的用户控件: ... ... 这会产生以下错误: System.Web.UI.HtmlControls.HtmlTable
我正在使用 c# ASP .Net、HtmlTable、HtmlTableRow、HtmlTableCell 创建一个表。 例如...我需要用 and 包裹一些细胞 我尝试使用 HtmlGener
显然这个错误是 VS 2012 中的一个已知错误,当您尝试将 a 设置为包含 or 元素的 runat="server"时。 好吧,我实际上使用的是 VS 2010,(尽管 IT 昨晚确实安装了
显然这个错误是 VS 2012 中的一个已知错误,当您尝试将 a 设置为包含 or 元素的 runat="server"时。 好吧,我实际上使用的是 VS 2010,(尽管 IT 昨晚确实安装了
我是一名优秀的程序员,十分优秀!