Edit This Code:
<!DOCTYPE html>
<html>
<body>

<h1>Hello World!</h1>
<button type="button" onclick="myFunction()">Set background image</button>

<script>
function myFunction() {
    document.body.style.backgroundColor = "#f3f3f3";
    document.body.style.backgroundImage = "url('img_tree.png')";
}
</script>

</body>
</html>


Result:
Try it Yourself - © w3schools.com
Privacy Policy