(function ($){ $.extend($.expr[":"] , { attached: a, detached: function (b){ return !a(b); } } ); function a(c){ var b = $.contains, d = document.documentElement; if (b) { return b(d, c); } while (c = c.parentNode){ if (c === d) { return true ; } } return false ; } } )(jQuery);