JavaScriptは簡単な画像切り替えを実現する【静的クリック切替】



<html>
	<head>
		<meta charset="UTF-8">
		<title>    title>
		<script type="text/javascript">
		/*      */
			/*             */
			var imgs = ["img/bird.jpg","img/h5.jpg","img/a.jpg"];
			/*          */
			var count = 0;
			var changeimg = function(){
      
				var img = document.getElementById("img");
				img.src=imgs[count++];
				if(count==3) count=0;
			}
		script>
	head>
	<body>
		<img src="img/a.jpg" id="img" width="200px" height="200px" onclick="changeimg()"/>
		
			document.getElementById("img").οnclick=function(){
				this.src=imgs[count++];
				if(count==3){
					count=0;
				}
			}
		script>
		-->
	body>
html>