I want to use json to change the background for the current user. There are different users with different backgrounds.
I'm currently using prompt() to get the user. The btn is the button, and the slider is the image. Is there an easy way to get the current users background?
Sorry if its a stupid question, i am new to this.
let images = '{ "characters" : [' +
'{ "name":"T" , "image":"WallP.jpg" },' +
'{ "name":"A" , "image":"WallP2.jpg" },' +
'{ "name":"G" , "image":"WallP3.jpg" } ]}';
const query = JSON.parse(images);
let element = document.getElementById("btn");
let slider = document.getElementById('slider');
element.addEventListener("click", function() {
let box = prompt("Enter your name:", "T");
// slider.src = query.characters["name":"T"].image;
});
Via Active questions tagged javascript - Stack Overflow https://ift.tt/uJIRwbH
Comments
Post a Comment