I want to add a background image using a link that anyone can paste in the input, I can't figure out why the script isn't working for me or what else I need to add to make it work
function load(){
var img = document.getElementById("link").value;
document.getElementById("background").style.backgroundImg = img;
body{
margin: 0;
}
.back{
height: 200px;
background-color: #000;
background-size: cover;
background-repeat: no-repeat;
}
<div id="background" class="back">
<input id="link" type="text" placeholder="pegar link">
<button onclick="load()">Añadir</button>
</div>
backgroundImgdoes not exist. You have to usebackgroundImage
. Also in CSS we usebackground-image: url("laImagen.jpg");
and notbackground-image:theImage.jpg;