为列表框的图片循环注册事件就行,点击列表框的图片改变body的backgroundImage的属性值url就行。
代码!
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>js图片</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" media="screen" href="main.css" />
<style>
*{
margin: 0;
padding: 0;
}
body{
background:url(img/1.jpg) no-repeat center center fixed;
background-size : cover;
}
li{
list-style: none;
}
.care{
overflow: hidden;
margin: 100px auto;
background-color: #ffffff;
width: 310px;
padding-top: 3px;
margin-left: 70%;
}