1if ($('.element').length) {
2 // there is at least one element matching the selector
3}
1$(function() {
2 var $button = $(".the_button");
3 alert (isStale($button));
4 $button.remove();
5 alert (isStale($button));
6});
7
8function isStale($elem)
9{
10 return $elem.closest("body").length > 0;
11};