if i click in body nothing change but if i clicked in image itself it changed why?
let element = document.querySelector("img");
document.body.addEventListener("click", function(e) {
element.src = "images/2.jpg";
})
<img src="x">
try to give the body a color using CSS. body by default takes the content height and 100% of the width. if you want to make the event happen when clicking on the screen you should apply the event on the HTML tag or give the body 100% width and height.
body {
width :100%;
height: 100%;
}