jquery check if element exists in div code example
Example 1: 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;
};
Example 2: jQuery exists function
if ($("#myElementID").length){
//I exist
}