javascript - jQuery: nth-child Selector throwing "undefined" and crashing site -



javascript - jQuery: nth-child Selector throwing "undefined" and crashing site -

$('#mapid').val($(".firstbox ul li:nth-child(" + mapi + ")").class()); returning undefined error loops indefinitely...

i tried doing: $('#mapid').val($(".firstbox ul li:nth-child(2)").class()); , same error occurs.

the elements undoubtedly exist, , script positioned @ bottom of page. no, not utilize wordpress (i saw mutual theme regarding error).

here html:

<div id="map-box" class="firstbox"> <ul> <li class="14" id="thelimit"> <div class="left"> <h1>the limit</h1> <span class="inf">a branching map. mix-n match of alot of themes 1 map. <p>recommended players: 3<br /> author: <a href="http://www.minecraftforum.net/user/18586-timetoslide/" target="_new">timetoslide</a></p></span> </div> <div class="right" style="position: relative"> <div style="width: 250px; height: 120; z-index: 6; position: absolute; top: 0px; height: 120px; left: 35px; cursor: pointer" class="righthover"></div> <div style="background: url('maps/thelimit.jpg'); width:250px;height:150px;overfow:hidden;border:none;position: relative; z-index: 1"> <div style="background: url('img/vignette.png') no-repeat center center; width: 100%; height: 100%; position: absolute; top: 0px; left: 0px; z-index: 2"></div> <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;"><div style="padding: 20px; padding-top: 40px;">see total list of maps...</div></div> <img src="img/border.png" style="z-index: 3" /> <div class="directions" style="z-index: 5"></div> </div> </div> </li> <li class="13" id="lavaseaofsurvival"> <div class="left"> <h1>lava sea of survival</h1> <span class="inf">try survive using resources provided. did mention you're floating above lava? <p>recommended players: 4<br /> author: <a href="http://www.minecraftforum.net/user/1021295-meh-own/" target="_new">meh_own</a></p></span> </div> <div class="right" style="position: relative"> <div style="width: 250px; height: 120; z-index: 6; position: absolute; top: 0px; height: 120px; left: 35px; cursor: pointer" class="righthover"></div> <div style="background: url('maps/lavaseaofsurvival.jpg'); width:250px;height:150px;overfow:hidden;border:none;position: relative; z-index: 1"> <div style="background: url('img/vignette.png') no-repeat center center; width: 100%; height: 100%; position: absolute; top: 0px; left: 0px; z-index: 2"></div> <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;"><div style="padding: 20px; padding-top: 40px;">see total list of maps...</div></div> <img src="img/border.png" style="z-index: 3" /> <div class="directions" style="z-index: 5"></div> </div> </div> </li> [etc...]

there may multiple elements in code having class=firstbox, , of may not have element trying access.

in case can seek child() function refer kid element of element having id map-box, may solve problem.

http://api.jquery.com/children/

javascript jquery

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -