Last Updated: February 25, 2016
·
1.912K
· iantearle

My most reused jQuery function

jQuery.fn.exists = function() {
    return this.length>0;
}

I have this handy function in every Javascript file I write for front end web design. Unbelievably handy every time.

if ($(element).exists()) {
    // Your code.
}

1 Response
Add your response