在jsp中如何做点击一个按钮实现不刷新页面,而显示下一条内容
1个回答
展开全部
<input type='button' value='上一张' onclick='getPrev()' /> <input type='button' value='下一张' onclick='getNext()' />
<div id='myArea'><img width='600' height='800' src='http://img.99space.com/01/fc/028.jpg' /></div>
<script>
var listArr = [
'http://img.99space.com/01/fc/028.jpg',
'http://img.99space.com/01/fc/027.jpg',
'http://img.99space.com/01/fc/026.jpg',
'http://img.99space.com/01/fc/025.jpg',
'http://img.99space.com/01/fc/024.jpg',
'http://img.99space.com/01/fc/023.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>
<div id='myArea'><img width='600' height='800' src='http://img.99space.com/01/fc/028.jpg' /></div>
<script>
var listArr = [
'http://img.99space.com/01/fc/028.jpg',
'http://img.99space.com/01/fc/027.jpg',
'http://img.99space.com/01/fc/026.jpg',
'http://img.99space.com/01/fc/025.jpg',
'http://img.99space.com/01/fc/024.jpg',
'http://img.99space.com/01/fc/023.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>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询