基本上我使用z-index並通過單擊按鈕,它應該採取背面圖片,並將其放在前面,反之亦然。我目前堅持試圖讓按鈕工作。我想通過以下方式讓我的幻燈片更改圖片:按一個按鈕應該將顯示的圖像更改爲按下的按鈕
<!DOCTYPE html>
<html lang="en">
<head>
<title>Lab 5, Part 1</title>
<meta charset="utf-8" />
<script type="text/javascript" src="stacking.js">
function Luka() {
var x = document.getElementById('anime1');
var z = x.style.zIndex
if (z == 10) z = 20;
else z = 10;
x.style.zIndex = z;
}
</script>
<style type="text/css">
.anime1 {
position: absolute;
top: 50px;
left: 50px;
z-index: 10;
}
.anime2 {
position: absolute;
top: 100px;
left: 100px;
z-index: 15;
}
</style>
</head>
<body>
<p>
<img class="anime1" id="anime1" height="300" width="450" src="http://images5.fanpop.com/image/photos/29300000/Megurine-Luka-megurine-luka-29391390-1680-1050.jpg" alt="(Picture of Luka)" />
<img class="anime2" id="anime2" height="300" width="450" src="http://orig06.deviantart.net/a28f/f/2015/079/9/a/hinata_final_lr_by_artgerm-d8me6vb.jpg" alt="(Picture of Hinata)" />
</p>
<input type="button" value="Luka" onclick="Luka();">
<input type="button" value="Hinata" onclick="Hinata();">
</body>
</html>
這工作完美。謝謝 –