check element exist on page or not jquery code example
Example 1: jquery for element which doesnt exist on page load
$('body').on('click', '.my_class', function(event) { ...
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;
};