代码部分
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="jquery-3.1.1.min.js"></script>
</head>
<body>
<div class="background-picture" style="width:1000px;height:1000px;background-image:url(img/1.jpg)" id="divtest">
<div class="col-md-6" style="width:500px;height:1000px;float:left" >
<button id="pic_left" style="height:1000px;width:500px;background:none;border:none;outline:none" onclick="picChange()">点击前一页</button></div>
<div class="col-md-6" style="width:500px;height:1000px;float:left" >
<button id="pic_right" style="height:1000px;width:500px;background:none;border:none;outline:none">点击前一页</button></div>
</div>
<script>
function picChange() {
$('#divtest').css('background-image','url(img/2.jpg)')
}
}
</script>
</body>
</html>
代码实现部分
···
<script>
function picChange() { //方式按钮事件
$(function () {
$('#divtest').css('background-image','url(img/2.jpg)') //找到div样式标签img/2.jpgdivtest 并修改图片img/2.jpg
}
}
</script>
···