jQuery: nth-child Selector throwing "undefined" and crashing site
<p><code>$('#mapid').val($(".firstbox ul li:nth-child(" + mapi + ")").class());</code> is returning an undefined error that loops indefinitely...</p>

<p>I even tried doing: <code>$('#mapid').val($(".firstbox ul li:nth-child(2)").class());</code> and the same error occurs.</p>

<p>The elements undoubtedly exist, and the script is positioned at the bottom of the page. No, I do not use Wordpress (I saw that was a common theme regarding the error).</p>

<p>Here is the HTML:</p>

<pre><code>&lt;div id="map-box" class="firstbox"&gt;
        &lt;ul&gt;
                        &lt;li class="14" id="thelimit"&gt;
                &lt;div class="left"&gt;
                    &lt;h1&gt;The Limit&lt;/h1&gt;
                    &lt;span class="inf"&gt;A branching map. A mix-n match of alot of themes into one map.                    &lt;p&gt;Recommended Players: 3&lt;br /&gt;
                    Author: &lt;a href="http://www.minecraftforum.net/user/18586-timetoslide/" target="_new"&gt;timetoslide&lt;/a&gt;&lt;/p&gt;&lt;/span&gt;
                &lt;/div&gt;

                &lt;div class="right" style="position: relative"&gt;
                    &lt;div style="width: 250px; height: 120; z-index: 6; position: absolute; top: 0px; height: 120px; left: 35px; cursor: pointer" class="righthover"&gt;&lt;/div&gt;
                    &lt;div style="background: url('maps/thelimit.jpg'); width:250px;height:150px;overfow:hidden;border:none;position: relative; z-index: 1"&gt;
                    &lt;div style="background: url('img/vignette.png') no-repeat center center; width: 100%; height: 100%; position: absolute; top: 0px; left: 0px; z-index: 2"&gt;&lt;/div&gt;
                        &lt;div class="seeList" style="width: 100%; height: 100%; background: url(img/cbg.png) repeat; color: white; font-family: Georgia, 'Times New Roman'; font-size: 24px; margin: 0; padding: 0; font-style: italic; text-align: center; z-index: 1; display: none;"&gt;&lt;div style="padding: 20px; padding-top: 40px;"&gt;See full list of maps...&lt;/div&gt;&lt;/div&gt;
                        &lt;img src="img/border.png" style="z-index: 3" /&gt;
                        &lt;div class="directions" style="z-index: 5"&gt;&lt;/div&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
            &lt;/li&gt;
                    &lt;li class="13" id="lavaseaofsurvival"&gt;
                &lt;div class="left"&gt;
                    &lt;h1&gt;Lava Sea of Survival&lt;/h1&gt;
                    &lt;span class="inf"&gt;Try to survive by using only the resources provided. Did we mention you're floating above lava?                    &lt;p&gt;Recommended Players: 4&lt;br /&gt;
                    Author: &lt;a href="http://www.minecraftforum.net/user/1021295-meh-own/" target="_new"&gt;Meh_Own&lt;/a&gt;&lt;/p&gt;&lt;/span&gt;
                &lt;/div&gt;

                &lt;div class="right" style="position: relative"&gt;
                    &lt;div style="width: 250px; height: 120; z-index: 6; position: absolute; top: 0px; height: 120px; left: 35px; cursor: pointer" class="righthover"&gt;&lt;/div&gt;
                    &lt;div style="background: url('maps/lavaseaofsurvival.jpg'); width:250px;height:150px;overfow:hidden;border:none;position: relative; z-index: 1"&gt;
                    &lt;div style="background: url('img/vignette.png') no-repeat center center; width: 100%; height: 100%; position: absolute; top: 0px; left: 0px; z-index: 2"&gt;&lt;/div&gt;
                        &lt;div class="seeList" style="width: 100%; height: 100%; background: url(img/cbg.png) repeat; color: white; font-family: Georgia, 'Times New Roman'; font-size: 24px; margin: 0; padding: 0; font-style: italic; text-align: center; z-index: 1; display: none;"&gt;&lt;div style="padding: 20px; padding-top: 40px;"&gt;See full list of maps...&lt;/div&gt;&lt;/div&gt;
                        &lt;img src="img/border.png" style="z-index: 3" /&gt;
                        &lt;div class="directions" style="z-index: 5"&gt;&lt;/div&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
            &lt;/li&gt;
[etc...]
</code></pre>
