title: How to solve duplicate objects in dynamic loading page by using jQuery?
body: <p>I want to solve duplicate objects in dynamic loading content. Please look at the following source code for easier understand.</p>
  <p><strong>Base Page HTML With 1 Dynamic Loading Content</strong></p>
  <blockquote>
  <pre><code>&lt;body&gt;
       &lt;div id=&quot;general-div&quot;&gt;&lt;/div&gt;&gt;
       &lt;div id=&quot;div1&quot;&gt;&lt;/div&gt;
       &lt;div id=&quot;placeholder1&quot;&gt;
            Dynamic Content will be placed inside this.
  
            &lt;div class=&quot;inner-div&quot;&gt;&lt;/div&gt;
            &lt;div class=&quot;div1&quot;&gt;&lt;/div&gt;
       &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  </blockquote>
  <p>For script in header of this page, it's very easy to select &quot;general-div&quot; object like the following code.</p>
  <pre><code> $('#general-div')
  </code></pre>
  <p>It's quite easy for select &quot;inner-div&quot; object inside placeholder1. So I can select by using the below code.</p>
  <pre><code> $('.inner-div')
  </code></pre>
  <p>The above code could works perfectly. However, I can't use the above code when there is more than 1 duplicated object in the same document like the following HTML. The above code will return 2 objects that don’t what I want.</p>
  <p><strong>Base Page HTML - After load another dynamic loading content</strong></p>
  <blockquote>
  <pre><code>&lt;body&gt;
       &lt;div id=&quot;general-div&quot;&gt;&lt;/div&gt;&gt;
       &lt;div id=&quot;div1&quot;&gt;&lt;/div&gt;
       &lt;div id=&quot;placeholder1&quot;&gt;
            Dynamic Content will be placed inside this.
  
            &lt;div class=&quot;inner-div&quot;&gt;&lt;/div&gt;
            &lt;div class=&quot;div1&quot;&gt;&lt;/div&gt;
       &lt;/div&gt;
       &lt;div id=&quot;placeholder2&quot;&gt;
            Dynamic Content will be placed inside this.
  
            &lt;div class=&quot;inner-div&quot;&gt;&lt;/div&gt;
            &lt;div class=&quot;div1&quot;&gt;&lt;/div&gt;
       &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  </blockquote>
  <p><strong>Possible Solution 1</strong></p>
  <p>I must create specified jQuery object foreach script in dynamic loading content like the following code.</p>
  <pre><code> // Deep copy for jQuery object.
   var specfiedjQueryObj = $.extend(true, {}, jQuery);
  
   // modify find function in jQuery object.
   specfiedjQueryObj.fn.find = function(selector)
   {
        // by adding placeholder selector before eval result.
        return new specfiedjQueryObj.fn.old_find('#placeholder1 ' + selector);
   };
  
   // So, I can select any object in dynamic loading content.
   (function($)
   {
        // This result must be 1 object.
        $('.div1'); 
   })(temp);
  </code></pre>
  <p>Even though, this solution should be work great. But I found that jQuery is a very complex object. I found a lot of errors when I try to use it.</p>
  <p>Do you have any idea for solving this problem?</p>
  <p>PS.<strong>PlaceHolder Id is not a fixed Id. So, It's impossible to fixed it in selector rule. Moreover, I do not know exactly amount of element and position (first, last or middle) of it in document. Because of dynamic loading content will be displayed on a lot of page.</strong></p>