Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting child elements of dynamic generated content with jQuery AJAX
    primarykey
    data
    text
    <p>I have the following markup:</p> <pre><code>&lt;div class="item-content" style="display: block;"&gt; &lt;div class="item-menu"&gt; &lt;div id="ajax-content-1" style="display: block; opacity: 0;"&gt; &lt;div class="content chapters current-tab"&gt; &lt;div class="right"&gt; &lt;div id="chapters-container-8" style=""&gt; &lt;div id="chapters-container-7" style="display: none"&gt; &lt;div id="chapters-container-6" style="display: none"&gt; &lt;div id="chapters-container-5" style="display: none"&gt; &lt;div id="chapters-container-4" style="display: none"&gt; &lt;div id="chapters-container-3" style="display: none"&gt; &lt;div id="chapters-container-25" style="display: none"&gt; &lt;div id="chapters-container-1" style="display: none"&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>This is an ajax content , and I have several on the page. So what I want to do is display the 1st chapter-container visible on the page if i do this:</p> <pre><code>var first_div = $('div[id^=chapters-container-]:first'); first_div.show(); </code></pre> <p>it doesn't work because it shows all the visible chapter-containers divs on the page, I want it to show only the one for that ajax-content I have loaded. I tried doing something like:</p> <pre><code>var first_div = $('#ajax-content-' + id).closest('div[id^=chapters-container-]:first'); first_div.show(); </code></pre> <p>and </p> <pre><code>var first_div = $('#ajax-content-' + id).children('div[id^=chapters-container-]:first'); first_div.show(); </code></pre> <p>and it doesnt't work. btw i know the var id, so it is no error there. It simply doesn't make a good selection of what I want.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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