Load the file:
<script src="bounds-plugin.js"></script>
This plugin allows you insert a method into the chain to check how many items are in the collection at that point. For example, to ensure that you're removing exactly one element from the document, you can do:
$(sel).bounds(1,1).remove();
The general syntax is .bound(min,max). The method will complain if the length of the collection is less than min or greater than max. Equality yields no complaint.
If max is omitted, there's no maximum, so if you want to ensure that you are removing at least one element from the document, you do:
$(sel).bounds(1).remove();
Because this is intended to be a debugging aid, the plugin throws a RangeError if the bounds-check doesn't match.
As a shorthand for a common case, .one() is the same as .bounds(1,1)
As a shorthand for another common case, .some() is the same as .bounds(1)
You can also try to mouse-over this paragraph to make it red