I'm taking an online class and today's assignment should have taken 1/2 an hour but it took me 5. Eventually I quit trying because I couldn't figure out where I was going wrong. Upon doing my peer reviews, I saw a few examples of the correct code, and I now know I was going wrong with my use of quotation marks. But the working code looks like utter gibberish to me. Can you explain to me how this makes sense?
function upDate(previewPic){
document.getElementById('image').style.backgroundImage = "url" + "("+ previewPic.src+")";
}
I'm feeling frustrated because I spent all day searching everywhere online for how to use javascript to change a background image in CSS. I got close, but no one showed me any use of quotes that looked like this (nor did the instructor in my class). I don't know how I was supposed to be able to figure this out, nor how any of my classmates figured it out.
previewPic.srcusing CSS. After concatenating the different strings together, the second part will read something like this:url(http://imagelocation/image.jpg). Also have a look at his post, it is doing something similar: stackoverflow.com/questions/21760208/…