about jQuery find

if an element doesn’t exist, jQuery’s find method will not return undefined, instead it will create a new object and return it. So if you want to detect if an element exists or not, then you should use the length property. For example:

if (0 == $(‘div’).find(‘ul’).length) { // if div doesn’t contain any ul element

// do whatever

}