如何获取值< input type =" checkbox" />检查? [英] How to get values of <input type="checkbox" /> that are checked?

查看:94
本文介绍了如何获取值< input type =" checkbox" />检查?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在页面中有多个< input type =checkboxvalue =.../>

我需要得到每个被检查的< input> 做一些操作。

I need to get each of the <input> that is checked to do some operation.

我使用的是jQuery。

I'm using jQuery.

推荐答案

$("input[type=checkbox]:checked").each ( function() {
   alert ( $(this).val() );
});

或您可以使用

$("input:checkbox")

selector

如果所有复选框都在容器内,那么您可以使用

If all the checkboxes are inside a container then you can narrow the selector by using

$("#containerID input[type=checkbox]:checked" )

这篇关于如何获取值&lt; input type =&quot; checkbox&quot; /&gt;检查?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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