最好的办法让jQuery的所有选定的复选框VALUES [英] Best way to get all selected checkboxes VALUES in jquery

查看:123
本文介绍了最好的办法让jQuery的所有选定的复选框VALUES的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我期待得到已通过jQuery的选择所有的复选框值。

i am looking to get all checkboxes VALUE which have been selected through jquery.

推荐答案

您想要的:复选框:检查选择和地图以创建值的数组:

You want the :checkbox:checked selector and map to create an array of the values:

var checkedValues = $('input:checkbox:checked').map(function() {
    return this.value;
}).get();

如果您的复选框具有共享类这将是更快地使用,而不是说,例如。 $('mycheckboxes:检查'),或为了一个共同的名称 $('输入[名称=富]:勾选')

If your checkboxes have a shared class it would be faster to use that instead, eg. $('.mycheckboxes:checked'), or for a common name $('input[name="Foo"]:checked')

这篇关于最好的办法让jQuery的所有选定的复选框VALUES的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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