/ Published in: JavaScript

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.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
var checkBoxes = $(':checkbox'); var allAreSelected = (function() { for (i in checkBoxes.get()) { if (!checkBoxes[i].checked) { return false; } } return true; })();
Comments
