(function( $ ) {

    // extending jQuery
    $.fn.extend({
        inDom: function(){
            // assumption.
            // the element is in the dom if one of its parents is the body element
            if(1 === this.length){
                var p=this.parents("body");
                return (p.length>0);
            } else {
                var inDom = [];
                this.each(function(i, el){
                    inDom[i]=$(el).inDom();
                });
                return inDom;
            }
            return false;
        }
   });
})(jQuery);     

