Well, turns out, find() is wrong, and so is has(). Use filter(). The following code works:
- var images = $([]);
-
- $(".ad input[type=checkbox]").click(function() {
- var img = $(this).parent().find('img');
-
- if (images.filter(img).length > 0) {
- images = images.not(img);
- } else if (images.filter(img).length == 0) {
- images = images.add(img);
- }
- });