<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<script>
var n = 1;
function changePic(m){
return n = m;
}
function change(){
var myImg = document.getElementsByTagName("img")[0];
myImg.src = "images/0" + n + ".jpg";
if(n<5)nPP;
else n=1;
}
</script>
</head>
<body onload="setInterval(change,2000);">
<img src="images/01.jpg" alt="" width="200">
<div>
<a href="-sharp" onclick="changePic(1)"></a>
<a href="-sharp" onclick="changePic(2)"></a>
<a href="-sharp" onclick="changePic(3)"></a>
<a href="-sharp" onclick="changePic(4)"></a>
<a href="-sharp" onclick="changePic(5)"></a>
</div>
</body>
</html>
the above code is very simple, the picture every 2 seconds, change, this I understand.
the question is, when I click on the properties of a, such as travel, why does the picture jump to the travel picture?
changePic only returns the number 2 and does not see that it will change the picture?
change and changePic are two functions, and changePic cannot call the change function, huh?