js 点击两张图片来回切换

<script>
function change_pic() {
var imgObj = document.getElementById("caocao_pic");
if (imgObj.getAttribute("src", 2) == "../img/jpg/1.png") {
imgObj.src = "img/jpg/2.png";
} else {
imgObj.src = "../img/jpg/1.png";
}
}
</script>
<img
src="../img/jpg/1.png"
class="wujiang_pic_size"
id="caocao_pic"
onClick="change_pic()"
/>
posted @ 2019-08-27 16:20  熊大的小跟班  阅读(2991)  评论(0编辑  收藏  举报