jQuery:如何比较多个输入
如果同一表单中的多个输入都具有相同的值,如何比较它们?我需要检查它们是否都具有相同的值。
<input type="text" class="inputclass"/>
<input type="text" class="inputclass"/>
<input type="text" class="inputclass"/>
<input type="text" class="inputclass"/>
<input type="text" class="inputclass"/>
....
How can you compare multiple input in the same form if they ALL have the same value? I need to check if they all have the same value or not.
<input type="text" class="inputclass"/>
<input type="text" class="inputclass"/>
<input type="text" class="inputclass"/>
<input type="text" class="inputclass"/>
<input type="text" class="inputclass"/>
....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
试试这个:
这是 jsfiddle.net
http://jsfiddle.net/epignosisx/jzWUA/4/
更新===== =
正如@Anurag指出的,$.unique仅适用于DOM元素。这是一个不同的实现:
基本上使用一个真正返回唯一数组的函数。
Try this:
Here is the jsfiddle.net
http://jsfiddle.net/epignosisx/jzWUA/4/
UPDATE======
As @Anurag pointed out, $.unique is only for DOM elements. Here is a different implementation:
Basically uses a function that will truly return a unique array.
这应该可以解决问题 http://jsfiddle.net/EpYTh/
This should do the trick http://jsfiddle.net/EpYTh/
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects /Array/every
http://jsfiddle.net/zTSag/1/
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/every
http://jsfiddle.net/zTSag/1/