jquery 根据条件删除复选框
在 div 中有这些复选框(name =“val1”),并且在某个操作后这些复选框将被删除
<div name="navigation_b">
<label id="selectall">
select all
<input type="checkbox" name="selectall" />
</label>
<input type="checkbox" name="val1" />
<input type="checkbox" name="val1" />
<input type="checkbox" name="val1" />
<input type="checkbox" name="val1" />
<input type="checkbox" name="val1" />
</div>
如果所有复选框(name = val1)都被删除,那么 selectall 不应该是可见的。如何使用 jquery 执行此操作
In a div there are these check boxes(name="val1") and after a certain operation these check boxes are removed
<div name="navigation_b">
<label id="selectall">
select all
<input type="checkbox" name="selectall" />
</label>
<input type="checkbox" name="val1" />
<input type="checkbox" name="val1" />
<input type="checkbox" name="val1" />
<input type="checkbox" name="val1" />
<input type="checkbox" name="val1" />
</div>
If all the checkboxes(name =val1) are removed then the selectall should not be visible.How to do this using jquery
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
来源是这里,以及此处
编辑
您可以隐藏包含
selectall
的整个标签 -Source is here, and here
Edit
You could hide the entire label which contains
selectall
-您可以检查是否有任何复选框,如果没有,则删除
上面的标签未经测试,但我认为它非常接近。
You could check to see if there are any of the checkboxes and if not then remove the label
the above is untested but i think it's pretty close.
如果您的问题是自动显示全选复选框,当其他复选框被删除时,我认为 jQuery 不可能做到这一点,除非有一个 jQuery 运动的事件,当元素被删除。您必须使用其他答案中提供的最佳解决方案之一来手动显示全选复选框。
If your question is to auto-show the select all checkbox, when the others are removed, I don't think that is possible with jQuery, unless there is an event that jQuery sports which would fire when an element is removed. You'll have to show the select all checkbox manually may be by using one of the fine solutions provided in the other answers.