I am trying to simply update a span tag usign the following method…
<script type="text/javascript">
document.getElementById("myspan").innerHTML="newtext";
</script>
<span id="myspan"> hereismytext </span>
But i am getting the following error:
document.getElementById(“myspan”) is null
Any ideas as to what is causing this?
Cheers
Rich
That is because you need to add that javascript after the element (the element has to be first created in DOM for the javascript to see it):
Or use
window.onload: