gpt4 book ai didi

javascript - 隐藏所选项目并显示另一个项目,而不是 jquery 中的项目列表

转载 作者:行者123 更新时间:2023-11-28 19:13:10 25 4
gpt4 key购买 nike

我正在尝试从表行列表中切换带有文本框按钮。我正在使用 asp.net mvc 4jquery 1.9.1。问题是我单击的按钮被隐藏,但文本框出现在所有行中。我的代码如下,

<script>
$(document).ready(function () {
$('.btnDue').click(function () {
$(this).hide();
$('.txtDue').show();
});
});
</script>
<body>
@foreach(var item in Model.DueList)
{
<tr><td><button class="btnDue">Set Due</button>@Html.TextBoxFor(modelItem => item.due, new { @class = "txtDue", hidden = "hidden" })</td></tr>
}
</body>

如何只显示我单击按钮的文本框?非常需要这个帮助。交易。

最佳答案

您可以使用.next function选择以下具有 txtDue 类的同级:

$('.btnDue').click(function () {
$(this).hide();
$(this).next('.txtDue').show();
});

jsFiddle

关于javascript - 隐藏所选项目并显示另一个项目,而不是 jquery 中的项目列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30398335/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com