Note that there are some explanatory texts on larger screens.

plurals
  1. POgetElementsByClassName returns [] instead of asynchronous appended node
    primarykey
    data
    text
    <p>(I ask my question again after the first one was terribly formulated)</p> <p>I face the following problem:</p> <pre><code>&lt;div class="testA" id="test1"&gt;&lt;/div&gt; </code></pre> <p>The above written element is predefined. I now load a xml tree via <a href="http://lls-test.de/JS-Library/index.php" rel="nofollow">XMLHttpRequest &amp; Co.</a> delivering the following response:</p> <pre><code>&lt;response&gt; &lt;div class="colorSelector" id="0-0"&gt; &lt;div class="gbSelector" id="1-0"&gt; &lt;table style="none" id="2-0"&gt;&lt;/table&gt; &lt;/div&gt; &lt;/div&gt; &lt;/response&gt; </code></pre> <p>I now append the first <code>div</code> using</p> <pre><code>request.responseXML.getElementsByTagName("response")[0] .getElementsByTagName("div")[0] </code></pre> <p>into the predefined <code>div</code></p> <pre><code>&lt;div class="testA" id="test1"&gt; </code></pre> <p>The final document looks like this (checked using development tools):</p> <pre><code>&lt;div class="testA" id="test1"&gt; &lt;div class="colorSelector" id="0-0"&gt; &lt;div class="gbSelector" id="1-0"&gt; &lt;table style="none" id="2-0"&gt;&lt;/table&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>When I now try to get the element <code>&lt;div class="colorSelector" id="0-0"&gt;</code> using <code>getElementById("0-0")</code> I get the expected result.</p> <p>But using <code>getElementsByClassName("colorSelector")</code> returns <code>[]</code>.</p> <p>Did I miss something? Is it probably a leftover of the fact the nodes were of type <code>Element</code> and not <code>HTMLElement</code>?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    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