【发布时间】:2015-09-01 09:56:15
【问题描述】:
有人知道为什么会这样吗?放置图像,然后设置 setInterval 函数对其进行动画处理。然后将 HTML 添加到父 div 会中断动画。
document.getElementById('whiteboard').innerHTML = '<img id="mule" src="http://childscript.com/art/mule.png" />'; //image with id mule
csE = document.getElementById('mule');
setInterval(function(){ csE.style.transform = 'rotate(' + Math.floor(Math.random() * 90 -45) + 'deg)'; }, 100);
// following line breaks the code???
document.getElementById('whiteboard').innerHTML += 'hey';
JSfiddle:http://jsfiddle.net/gt6w3dhb/
【问题讨论】:
标签: javascript setinterval innerhtml