Skip to content Skip to sidebar Skip to footer

GetElementById(element).innerHTML Cache?

This is my page code: Marketing Tracking

Solution 1:

The reason your other values disappear is because when you do something.innerHTML += something it will rewrite the HTML for that zone (meaning what was there before is gone and will be replaced with fresh new HTML). What you probably want to do is something along this :

function add(){
    var div = document.createElement("div");
    div.innerHTML = '<span id="span [... the rest of the code ...]<br /></span>';
    document.getElementById("namevalues").appendChild(div);
}

Using appendChild won't alter the other element that are already in the div namevalues.


Solution 2:

Just a small thing but try using

<script type="text/javascript">

When I was using inner.document stuff I had all kinds of problems until I added that code.


Post a Comment for "GetElementById(element).innerHTML Cache?"