Checking if a jQuery selector doesn’t find any results [duplicate] May 12, 2023 by Tarik $.fn.exists = function () { return this.length !== 0; } Used like: $("#notAnElement").exists();