How can I check the existence of an element in jQuery?
The current code that I have is this:
if ($(selector).length > 0) { // Do something } <
In JavaScript, everything is 'truthy' or 'falsy', and for numbers 0 means false, everything else true. So you could write:
0
false
true
if ($(selector).length)
You don't need that >0 part.
>0