旋转功能在IE中不起作用

时间:2014-12-05 16:11:50

标签: javascript jquery internet-explorer

以下代码适用于所有浏览器,但不适用于Internet Explorer,即使我使用的是MsTransform,但它仍无效。

<!DOCTYPE html>
<html>
<head>
<script>
var looper;
var degrees = 0;
function rotateAnimation(el,speed){
 var elem = document.getElementById(el);
    elem.style.WebkitTransform = "rotate("+degrees+"deg)";
    elem.style.MozTransform = "rotate("+degrees+"deg)";
    elem.style.MsTransform = "rotate("+degrees+"deg)";
    elem.style.OTransform = "rotate("+degrees+"deg)";
looper = 
setTimeout(function()
{
    rotateAnimation(el,speed)
},speed);

    degrees++;
     if(degrees > 359){
         degrees = 1;
    }
}
</script>
</head>
<body>
<img id="img1" src="cog1.png" alt="cog1">
<script>rotateAnimation("img1",30);</script>
</body>  
</html> 

1 个答案:

答案 0 :(得分:1)

尝试小写:

elem.style.msTransform = "rotate("+degrees+"deg)";

Working Link