Forum Moderators: open

Message Too Old, No Replies

Advanced GetElementByID Element Selector

         

JAB Creations

10:58 am on Oct 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The deal is I had an element with an id that I had a script working perfectly fine with. However once I put that element inside another element the script failed to find the element.

First here is the snippet of script...

document.getElementById('menu');

Before (working)

<script src="script.js" type="text/javascript"></script>
<select id="menu">

After (not working)

<script src="script.js" type="text/javascript"></script>
<div>
<select id="menu">

The odd thing is even originally the script include line would only work when it was inside the body (as opposed to where I would put it in the head).

So the question again is, how do I select this element id correctly?

JAB Creations

11:52 am on Oct 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ah, nevermind! It was something totally unrelated! :)