Usually, when I’m selecting an element with jQuery, I would prefer it give me an error if it doesn’t find matching element.
For example, I just had a bug where this failed because I changed the class of a ul element:
$('ul.some-list').append(listItem)
Is there a convenient method for ensuring that my jQuery call matched an element?
You could make a plugin to use to ensure that the jQuery object is not empty:
Usage: