If element exists jQuery

If element exists jQuery

If you need to test whether an element exists n jQuery using a selector?
I have found this little snippet of code very handy so thought I would share how it’s done here.

Just replace #ElementID with the selector you want to use.

if ($('#ElementID').length != 0) {
//Your code here
alert('Element Found!');
}