点击图片后切换图片

<script>
function change()
{
var qiehuan=document.getElementById('id')
if (qiehuan.src.match("2s"))
{
qiehuan.src="/images/xiao_1s.gif";
}
else
{
qiehuan.src="/images/xiao_2s.gif";
}
}
</script>
<img id="id" onclick="change()"
src="/images/xiao_1s.gif" width="50" height="100">

==

qiehuan.src.match("2s") 的意思是src路径中有2s则是true

posted @ 2017-03-09 14:22  热爱生命热爱技术  阅读(32)  评论(0)    收藏  举报