Extending: https://stackoverflow.com/a/31047/235633
Is there a way I can extend this custom jQuery function to use a callback? Essentially I want to be able to have a list of selectors and detect their existence and if they exist, I need to show them.
Instead of writing a thousand if statements, I rather write one function that uses a callback and 'this'.
The guy wrote:
jQuery.fn.exists = function(){return this.length>0;}
if ($(selector).exists()) {
// Do something
}
But I need:
$('.selector1, .selector2, .selector3').exists(function({
$(this).show();
});