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 } <
You can use this:
// if element exists if($('selector').length){ /* do something */ }
// if element does not exist if(!$('selector').length){ /* do something */ }