jquery if present code example
Example 1: jquery check if element exists
// Check if an element currently exists
if ($('#element').length) {
}
Example 2: Is there an “exists” function for jQuery
if ($(selector).length)
// Check if an element currently exists
if ($('#element').length) {
}
if ($(selector).length)