<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=<>, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
window.οnlοad=function(){
var image=document.querySelectorAll('img');
for(var i=0;i<image.length;i++){
image[i].οnclick=function(){
document.body.style.backgroundImage='url('+this.src+')';
}
};
}
</script>
<style>
*{
margin: 0px;
padding: 0px;
}
body{
width: 1200px;
height: 600px;
margin: 0px auto;
display: flex;
}
img{
margin-top: 100px;
width: 300px;
height: 200px;
}
</style>
<img src="../code7/image/1.jpg">
<img src="../code7/image/2.jpg">
<img src="../code7/image/3.jpg">
<img src="../code7/image/4.jpg">
</body>
</html>