如果我有这个HTML:
<input type="button" />
<input type="button" />
<input class="btn" type="button" />
<div class="btn"></div>
<div class="btn"></div>
Run Code Online (Sandbox Code Playgroud)
我在jQuery对象中有3个按钮..说var buttons = $(':button');.
然后我有另一个具有不同3组元素的对象,其中一个元素是相同的: var nextButtons = $('.btn');
是否有jQuery方法检查所有元素是否相同?is()如果任何元素匹配,似乎返回true .
编辑:
我的意思是以完全相同的方式进行比较is().我想is(),对于第二组中的每一组,此函数将调用第一组中的每个元素.
内置任何东西,但它很容易做到:
$.fn.all = function(selector) {
return this.filter(selector).length == this.length;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
93 次 |
| 最近记录: |