Thursday 15 March 2012

javascript - Targeting an ID that is rendered by a script -


I am using a nifty short script called tabfire ()

Now, long Less story, this script, which I play in my head tag, and and ; & Gt; s with & lt; Ul & gt; In addition, in the head tag, it is in these & lt; A & gt; s creates an ID when I inspect the loaded site, then I can clearly see the ID tag. However, I can not call them using getElementById. I

  & lt; Script & gt; I am using Document.getElementById ('rightpanelnav1') = '200px' style.padding & Lt; / Script & gt;   

In the different parts of my code as a sample script, but no benefit. I am thinking of weather that this is a placement or order in which these things are defined in my code which is not being identified by ID. What do you think?

EDIT: I received a great reply below, but I still can not find 'rightpanelnav1' to register on-club events ...? This is one, there should be no problem, is not it? And when I click it, the whole page has been loaded for several seconds ...

< P> First, in order to use an element in the DOM, the element must be a part of the DOM ( document ). So if you put your code <; Script & gt; With the getElementById in the place where the element is loaded, it will not see the element in the DOM.

Secondly, it is highly likely that this library will be used by you, its amendment on page load will mean, that would mean that you have your & lt; Script & gt; It does not matter at the place of , look at these elements before walking.

As a result, you should also wait for your script, and do this:

  window.onload = function {document .getElementById ('rightpanelnav1') = ' 200px 'style.padding. };   

or for click event

  window.onload = function () {document.getElementById ('rightpanelnav1'). Onclick = function () {alert ("clicked!"); }; };    

No comments:

Post a Comment