jquery if something exists than code example
Example 1: check element exist in jquery
if ($('.element').length) {
// there is at least one element matching the selector
}
Example 2: Is there an “exists” function for jQuery
if ($(selector).length)
Example 3: jQuery exists function
if ($("#myElementID").length){
//I exist
}