Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This code is an infinite loop if <code>node !== "none"</code> when the loop starts:</p> <pre><code>while (node !== "none") { (lastnode++); (a++); } </code></pre> <p>Nothing in the loop changes the value of <code>node</code> so once the loop starts, it will never stop.</p> <p>Also, this syntax is odd and not required:</p> <pre><code>(lastnode++); </code></pre> <p>Remove the parens so it's just:</p> <pre><code>lastnode++; </code></pre> <p>Using the jQuery library (which makes cross browser DOM manipulation sooo much easier), here's some code to find the first item in a list that is set to display: none.</p> <p>Here's a working version: <a href="http://jsfiddle.net/jfriend00/Um95a/" rel="nofollow">http://jsfiddle.net/jfriend00/Um95a/</a></p> <p>and the code:</p> <p>HTML:</p> <pre><code>&lt;ul id="container"&gt; &lt;li class="show"&gt;First item&lt;/li&gt; &lt;li class="hide"&gt;Second item&lt;/li&gt; &lt;li class="show"&gt;Third item&lt;/li&gt; &lt;li class="show"&gt;Fourth item&lt;/li&gt; &lt;li class="show"&gt;Fifth item&lt;/li&gt; &lt;/ul&gt; &lt;br&gt;&lt;br&gt; &lt;div id="result"&gt;&lt;/div&gt; </code></pre> <p>CSS:</p> <pre><code>.hide {display: none;} </code></pre> <p>Javascript (run after page is loaded):</p> <pre><code>function findFirstDisplayNoneChild(parent) { var result = null; $("#" + parent + " li").each(function() { if ($(this).css("display") == "none") { result = this; return(false); // break out of each() function } }); return(result); } var hidden = findFirstDisplayNoneChild("container"); if (hidden) { $("#result").html("Hidden Element: '" + hidden.innerHTML + "'"); } else { $("#result").html("No hidden elements found"); } </code></pre> <p>Or, any even simpler version of the code using the :hidden selector:</p> <p><a href="http://jsfiddle.net/jfriend00/Xsgmu/" rel="nofollow">http://jsfiddle.net/jfriend00/Xsgmu/</a></p> <pre><code>function findFirstDisplayNoneChild(parent) { return($("#" + parent + " li:hidden").get(0)); } </code></pre>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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