Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4056116
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:47:11+00:00 2026-05-20T14:47:11+00:00

lets say you set var $this = jQuery(this); how can you search the dom

  • 0

lets say you set var $this = jQuery(this); how can you search the dom for that element. $this.size() Does not work because it’s not searching the dom for that element. I need to basically detect if $this has been removed from the dom and stop an interval.

Update code requested:


    jQuery(document).find('div.ctalk').each(function(){
        var delay;
        var $this = this;

        activateLive = function($this) {


            clearInterval(delay);
            delay = setInterval(function(){

                if(jQuery($this).size() != '0') {

                    fn.actJSON('0', $this, 'update=1&');

                }else {
                    alert('kill it');
                    clearInterval(delay);
                }

            }, 10000 ); 

        }


        if(!jQuery(this).data('init')) {

            jQuery(this).data('init', '1'); 
            fn.activateBinds($this);
            activateLive($this);
        }

    });

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T14:47:11+00:00Added an answer on May 20, 2026 at 2:47 pm

    This would probably be the first time I’ve advocated the use of .is() for anything, but it does make this quite a simple task:

    if (!$(this).parents().is("body")) {
        // Node has been disconnected
    }
    

    You can swap "body" for "html" if you want to check nodes anywhere in the document.

    IE also has a proprietary sourceIndex property that would do the job with slightly better performance:

    if (this.sourceIndex == -1 || !$(this).parents().is("body")) {
        // Node has been disconnected
    }
    

    Extra Update: I knew there was a couple of other methods for this, they were scratching at the back of my mind but I couldn’t quite remember. Modern browsers have the DOM Level 3 method .compareDocumentPosition(), so you can do the whole thing without jQuery if anyone ever needs to.

    if (this.sourceIndex == -1 || document.compareDocumentPosition(this) & 0x01) {
        // Node has been disconnected
    }
    

    The other method I was thinking of is IE’s .contains() method, which also works. However, using that would require a check that the function is defined first so it’s easier to just stick with sourceIndex.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not getting the syntax right. Lets say I have this... #include <set> ...
Lets say I have this data set... var a = [5,6,7]; var b =
Lets say I have a class like this: Class User { var $id var
Lets say I have a WCF service that a client can use to receive
Lets say I have model inheritance set up in the way defined below. class
Lets say you have a set: foo = {1, 2, 3, 4, 5} In
I have a set of ids in a table (column id), lets say from
I have a result set in MS-SQL within a stored procedure, and lets say
In my action class I have a Map<Long, Set<String>> attribute, named accountsMap. Lets say
let's say I have this set of HTML-markup and CSS #CSS .inputhelp_text { background:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.