简体   繁体   中英

innerHTML in ie6/ie7 bug?

I user the innerHTML for the code:

<div>
   <span id="tag"></span>
</div>

var i = 15;
function timer(){
   var div = document.getElementById("tag");
   i--;
   setInterval(function(){
      div.innerHTML = i;// use innerHTML
      //div.removeChild(div.childNodes[0]);
      //div.appendChild(document.createTextNode(i));
      i--;
   },15000);
}

timer();

the ff,safari,chrome is ok, but in ie8 value is no change;

Following semicolon is 2 byte character. try again after change to 1 byte character.

  div.innerHTML = i;// use innerHTML 

Why don't you try using jQuery for this kind of operations (reading/writing to elements)? That library is designed mainly to take away all the fuss with different browsers and browser versions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM