Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is this not valid code?
    primarykey
    data
    text
    <p>I have this piece of code in my javascript file (I'm working with YUI):</p> <pre><code>var levels = [2, 3, 4, 5, 6, 7, 8, 9]; for(var i = 0; i &lt; levels.length; i++) { var level = levels[i]; Y.all(".level"+level).get('parentNode').addClass("category_level"+level); }; </code></pre> <p>Now, if I have this right in the end of my javascript file, it works fine. However if I have this ahead of other code, none of my other code (functions) work anymore.</p> <p>I have further isolated the problem to this piece of code: <strong>.get('parentNode')</strong> - When I take that bit out, all the other code and functions work again.</p> <p>I am not sure, but I think that I might have to something along the lines of:</p> <pre><code>var nodes = Y.all(".level"+level); nodes.each(function(node){ ... node.get('parentNode')....... </code></pre> <p>but I am struggling getting this applied to my piece of code at the top.</p> <p>Thanks!</p> <p><strong>UPDATE</strong></p> <p>This piece of code is not valid for some reason:</p> <pre><code>var levels = [2, 3, 4, 5, 6, 7, 8, 9]; for(var i = 0; i &lt; levels.length; i++) { var level = levels[i]; Y.all(".level"+level).get('parentNode').addClass("category_level"+level); }; </code></pre> <p>When I paste this into <a href="http://www.jslint.com/" rel="nofollow">http://www.jslint.com/</a> it is so wrong that it cannot even scan it! "JavaScript syntax error and cannot continue to reliably parse the program"</p> <p>What is so wrong with this piece of code? It says to "Move 'var' declarations to the top of the function" - but when I do that it just says the same thing again.</p> <p>Is there perhaps anybody that can tell me what is wrong with that piece of code. Or is it perhaps too difficult or sthing and should be done in an easier way?</p> <p>Thanks!</p>
    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.
 

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