jquery - 如何在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 需要帮助
解决方案
如果你有唯一的 id,那么你直接应用隐藏和显示。
$('#convrt').hide();
$('#cancel').show();
推荐阅读
- vue.js - Visual Studio Code:已设置断点但尚未绑定 - Vue.js
- python - 基于子集的递归python匹配算法工作太慢
- scrapy - Splash 没有正确加载 javascript 来抓取网站(scrapy-splash)
- java - 捕获异常后在多个try-catch语句场景中继续程序执行
- django - 反正怎么逃?Django url 中的字符?
- javascript - ace 编辑器宽度更改丢失内容
- javascript - 玩笑:在测试块之间共享异步代码
- amazon-web-services - 具有特定前缀的用于自动复制的 Amazon S3 标签?
- git - 如何解决 TeamCity GitVersion 无限循环错误?
- json.net - 不同的 Newtonsoft.Json.dll dotnet 发布与使用 Visual Studio 发布