Javascript 除了.each()函数之外,还有其他方法可以使用jQuery将输入字段中的信息收集到数组中吗?

Javascript 除了.each()函数之外,还有其他方法可以使用jQuery将输入字段中的信息收集到数组中吗?,javascript,jquery,arrays,Javascript,Jquery,Arrays,我有一种形式像 <form id="myform"> <input type="text" name="myfield[]" class="qwerty" /><br /> <input type="text" name="myfield[]" class="qwerty" /><br /> <input type="text" name="myfield[]" class="qwerty" /><br /

我有一种形式像

<form id="myform">
  <input type="text" name="myfield[]" class="qwerty" /><br />
  <input type="text" name="myfield[]" class="qwerty" /><br />
  <input type="text" name="myfield[]" class="qwerty" /><br />
  <input type="text" name="myfield[]" class="qwerty" /><br />
  <input type="text" name="myfield[]" class="qwerty" /><br />
  <input type="button" id="mybutton" value="clickme" />
</form>
这将创建一个循环。还有其他简单/有效的方法吗?

您可以使用
.map()
.get()
来实现所需的功能

试试看

请阅读了解有关
.map()

编辑:

使用以下代码查找有效输入的数量

$('.qwerty').filter(function(){
     return ($.trim($(this).val()) !== '');
}).length

如果您需要从本表格中提出请求,则可能

$('#myform').serialize()

可以帮助您

项目!=“
-red flag@ŠimeVidas只是为了忽略空表单字段我会告诉您JavaScript类型强制,但我不想破坏您的元旦节
:p
。只要使用
==。谢谢@ŠimeVidas(两个)
:)
这很管用,兄弟。再多一点帮助,有没有办法获得有效输入的数量?@blasteralfredψ是的,像这样的任务很简单。只要告诉什么条件可以告诉一个文本框是有效的。
如果(item!='')使它有效
$('.qwerty').filter(function(){
     return ($.trim($(this).val()) !== '');
}).length
$('#myform').serialize()