第四篇 js原生学习-初级-练习03 图片简单切换
图片切换
<script>
var oImg = document.getElementById('img1');
var onOff = true;
oImg.onclick = function(){
//alert(1);
if (onOff) {
oImg.src = 'img/3.jpg';
onOff = false;
}else{
oImg.src = 'img/1.jpg';
onOff = true;
}
}
</script>