首页 > 解决方案 > 如何在html列表视图中隐藏和显示哪个是IEnumerable模型表的一部分

问题描述

这是一个 @model IEnumerable 并且取决于循环 @Foreach(var item in model)

我有一些按钮,我想隐藏一个并显示另一个第二个按钮不显示

<style>
    .clv1{
        display: none;
    }
</style>

<td id="cv" class="con1">
    <input type="submit" id="convrt" name="convrt" value="Add To INv No:- @ViewBag.NewINVNo1" class="convrt btn btn-success " />
</td>
<td id="clv" class="clv1">
    <input type="submit" id="cancel" name="cancel" value="Cancel this " class="convt11 btn btn-danger btn-group-sm " />
</td>

在这里我想隐藏转换按钮并显示取消按钮

我在jQuery中试过这个

$(this).closest('tr td:nth-child(9)').hide();
$(this).closest('tr td:nth-child(10)').show();

但孩子 9 隐藏得很好,但他不能显示孩子 10 需要帮助

标签: jqueryhtmlasp.net-mvc

解决方案


如果你有唯一的 id,那么你直接应用隐藏和显示。

$('#convrt').hide();
$('#cancel').show();

推荐阅读