check is jquery function exists code example
Example 1: Is there an “exists” function for jQuery
if ($(selector).length)
Example 2: jQuery exists function
if ($("#myElementID").length){
//I exist
}
if ($(selector).length)
if ($("#myElementID").length){
//I exist
}