Prev: FAQ Topic - My element is named myselect[], how do I access it? (2010-04-09)
Next: navigator.appName
From: FAQ server on 14 Apr 2010 19:00 ----------------------------------------------------------------------- FAQ Topic - Why does my code fail to access an element? ----------------------------------------------------------------------- An element can only be accessed after it exists in the document. Either: A) include your script after the HTML element it refers to, or B) use the ` "load" ` event to trigger your script. Example A: <div id="snurgle">here</div> <script type="text/javascript"> // Don't forget var. var snurgleEl = document.getElementById("snurgle"); window.alert(snurgleEl.parentNode); </script> Example B: // In the HEAD. <script type="text/javascript"> window.onload = function(){ var snurgleEl = document.getElementById("snurgle"); }; </script> * * invalid HTML * two elements with the same ` name ` or ` id ` * use of an unsafe name: http://jibbering.comnames/. The complete comp.lang.javascript FAQ is at http://jibbering.com/faq/ -- The sendings of these daily posts are proficiently hosted by http://www.pair.com.
From: Garrett Smith on 14 Apr 2010 19:33 FAQ server wrote: > ----------------------------------------------------------------------- > FAQ Topic - Why does my code fail to access an element? > ----------------------------------------------------------------------- [...] > * > * invalid HTML > * two elements with the same ` name ` or ` id ` > * use of an unsafe name: http://jibbering.comnames/. > Looks like translation to plain text omitted the preceding heading: "Other problems can include:". -- Garrett comp.lang.javascript FAQ: http://jibbering.com/faq/
From: toby.oconnell on 15 Apr 2010 00:29
On Apr 14, 4:00 pm, "FAQ server" <javascr...(a)dotinternet.be> wrote: > ----------------------------------------------------------------------- > FAQ Topic - Why does my code fail to access an element? > ----------------------------------------------------------------------- > > * use of an unsafe name:http://jibbering.comnames/. http://jibbering.com/faq/names/ |