简体   繁体   English

如何更改JavaScript数组中的backgroundImage url?

[英]How do I change backgroundImage url in JavaScript array?

Hi I know that this is probably simple but I just cant get the url of the flag and the image to change. 嗨,我知道这可能很简单,但我只是无法获取标志的网址和要更改的图像。 I'm pretty new to JavaScript but i've managed to get the three pieces of text working. 我对JavaScript非常陌生,但是我设法使这三段文字起作用了。 Help please! 请帮助! :) :)

function changeinfo(person){
    document.getElementById("personname2").innerHTML = window[person][0];
    document.getElementById("country2").style.backgroundImage = "url('')", [1];
    document.getElementById("image2").style.backgroundImage = "url('')",[2];
    document.getElementById("ratingnum3").innerHTML = window[person][3];
    document.getElementById("ratingnum4").innerHTML = window[person][4];
}

var tango = ["Tango",
    'flags/uk.png', 
    "images/tango.jpg", 
    "2", 
    "3"];

Try ... 尝试...

document.getElementById("country2").style.backgroundImage = "url('" + window[person][1] + "')";
document.getElementById("image2").style.backgroundImage = "url('" + window[person][2] + "')";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM