see if an element exits jquery code example
Example 1: check element exist in jquery
if ($('.element').length) {
// there is at least one element matching the selector
}
Example 2: jquery check if element still exists
$(function() {
var $button = $(".the_button");
alert (isStale($button));
$button.remove();
alert (isStale($button));
});
function isStale($elem)
{
return $elem.closest("body").length > 0;
};