I am a javascript learner. I have a little script that is almost finished. I just want to put DIV's around the html select attribute. If I do that, my script won't work. Why? Is this forbidden?
http://jsfiddle.net/triggerload/XHWwg/159/
<div id="test">
<select class="valueList" name="n1">
<option selected value="0"></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
</select>
</div>
I think that it is because parent is no longer question_holder. It is now the id of the div.
So holder should now call document.getElementById("test")
The problem almost certainly has to do with the way you are trying to grab the
select
element:You're checking only for direct child nodes of
question_holder
, but when you add yourdiv
theselect
element is no longer a direct child ofquestion_holder
, it is a child of thediv
that you added. So of course it does not get returned by yourgrabFormSelect()
code.As a quick fix, you can try: