循环jQuery对象并返回值

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了循环jQuery对象并返回值相关的知识,希望对你有一定的参考价值。

Returning a boolean inside of jQuery's $.each() function will only break the loop. To get a return value, you can convert the jQuery object to array and use a regular for loop in javascript.
  1. var checkBoxes = $(':checkbox');
  2.  
  3. var allAreSelected = (function() {
  4.  
  5. for (i in checkBoxes.get()) {
  6. if (!checkBoxes[i].checked) {
  7. return false;
  8. }
  9. }
  10.  
  11. return true;
  12.  
  13. })();

以上是关于循环jQuery对象并返回值的主要内容,如果未能解决你的问题,请参考以下文章