制作一个按钮切换图片,为什么点击按钮不显示图片啊
<!DOCTYPE html><html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<script type="text/javascript">
var listArr = [
'F:\html\555.jpg',
'F:\html\666.jpg',
'F:\html\777.jpg',
];
var currPic = 0;
function getPrev() {
var myArea = document.getElementById('myArea');
currPic = currPic - 1;
if (currPic < 0) {
currPic = listArr.length - 1;
}
myArea.firstChild.src = listArr[currPic];
}
function getNext() {
var myArea = document.getElementById('myArea');
currPic = currPic + 1;
if (currPic >= listArr.length) {
currPic = 0;
}
myArea.firstChild.src = listArr[currPic];
}
</script>
</head>
<body>
<input type="button" value="上一张"onclick="getPrev()" />
<input type="button" value="下一张"onclick="getNext()" />
<div id='myArea'><img width='800' height='500' src='F:\html\22.png' /></div>
</body>
</html>