重置页面上的所有复选框而不循环 [英] Reset all checkboxes on page without looping

查看:71
本文介绍了重置页面上的所有复选框而不循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有可能重置页面上的所有复选框(标记未选中)而不使用jQuery循环?

I was wondering if it was possible to reset all the checkboxes (mark them unchecked) on the page without looping using jQuery?

推荐答案

您可以使用单个选择器查找所有选中的复选框,并从中删除已检查属性。 jQuery将通过循环在内部执行此操作,但您不必自己编写循环:

You can use a single selector to find all the checked checkboxes, and remove the 'checked' attribute from them. jQuery will do this internally by looping, but you will not have to write a loop yourself:

 $(':checkbox:checked').removeAttr('checked');

参见 :复选框 :已选中 选择器。

See the :checkbox and :checked selectors.

这篇关于重置页面上的所有复选框而不循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆