Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I find the children of Ajax added content and then perform a function
    text
    copied!<p>I have html </p> <pre><code>&lt;ul id="main"&gt; &lt;li id="A100"&gt; &lt;ul class="slides"&gt; &lt;li&gt;&lt;img1&gt;&lt;/li&gt; &lt;li&gt;&lt;img2&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li id="A99"&gt; &lt;ul class="slides"&gt; &lt;li&gt;&lt;img1&gt;&lt;/li&gt; &lt;li&gt;&lt;img2&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>then I add the following by ajax.</p> <pre><code>&lt;li id="A98"&gt; &lt;ul class="slides"&gt; &lt;li&gt;&lt;img1&gt;&lt;/li&gt; &lt;li&gt;&lt;img2&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li id="A97"&gt; &lt;ul class="slides"&gt; &lt;li&gt;&lt;img1&gt;&lt;/li&gt; &lt;li&gt;&lt;img2&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; </code></pre> <p>So it looks like this</p> <pre><code> &lt;ul id="main"&gt; &lt;li id="A100"&gt; &lt;ul class="slides"&gt; &lt;li&gt;&lt;img1&gt;&lt;/li&gt; &lt;li&gt;&lt;img2&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li id="A99"&gt; &lt;ul class="slides"&gt; &lt;li&gt;&lt;img1&gt;&lt;/li&gt; &lt;li&gt;&lt;img2&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li id="A98"&gt; &lt;ul class="slides"&gt; &lt;li&gt;&lt;img1&gt;&lt;/li&gt; &lt;li&gt;&lt;img2&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li id="A97"&gt; &lt;ul class="slides"&gt; &lt;li&gt;&lt;img1&gt;&lt;/li&gt; &lt;li&gt;&lt;img2&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>What is the correct syntax to do </p> <pre><code>$("#main").children(with id after ids ending with 99).nextAll.each(function(){ $(this).something({ //do stuff. }); }); </code></pre> <p>I have to use children() and not find(), because I want to do "something" only on level 1 <code>&lt;li&gt;.</code></p> <p>EDIT: I will "do something" on. ajax success. (if that helps in understanding the question any better)</p> <p><strong>EDIT2</strong>: Thanks for all suggestions. I found this. Even before I do ajax, I "do something" on the existing html. (ie A100, A99)</p> <p>If I use</p> <pre><code>$("#main li").each(function() { }); </code></pre> <p><strong>it works</strong> as expected, but IF I use </p> <pre><code> $("#main").children("li").each(function() { }); </code></pre> <p>It is <strong>not working</strong>. Whats the difference here? If I know that, I think i can fix the issue at hand.</p> <p>May be something like this will work? I tried this and did not work, but may be I am doing it wrong?</p> <pre><code>$("#main li[id$='A99']").nextAll().each(function() { }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload