Js实现图片切换

    
    
<img id = "dim" src="images/D2.png" width="100%" height="100%" sizes="any"/>
<script>

function on(){
    document.getElementById("dim").src='images/D1.png';
}
function off(){
    document.getElementById("dim").src='images/D2.png';
}
function ooff(){
    document.getElementById("dim").src='images/D3.png';
}
var x = 0;
setInterval(function (){
    if(x == 1){
    on();
    }else if(x == 2){
        ooff();
    }else if(x == 3){
        off();
        x = 0;
    }
    x++;
}
,1000);


</script>

您可能还喜欢...