Struggling to utilize the text entered into a text input field as a background image URL. Ensuring it is valid is key.
This snippet displays what has been attempted so far...
CSS:
body {
margin: 0px;
padding: 0px;
border: 0px;
}
.bgimg {
background-image:url('http://192.168.0.4/DesktopVersion/Inc/Images/Background/DarkWood.jpg');
}
JavaScript:
$("#SetBG").click(function() {
var URL = document.getElementById("ImageURL").text();
$(".bgimg").css('background-image',"url(" +URL +")");
});
HTML:
<input type="text" id="ImageURL"></input>
<button id="SetBG">Set Background</button>
A more knowledgeable individual may be able to pinpoint why this approach isn't functioning as desired.