My array is not loading pictures to the html [on hold]

denis

New Member
#1
I believe I have this coded correctly, but I'm not getting the image to show up.

Here is the array of questions, answers and the image:
Mã:
var questions = [

question:"Where should choking victims place their hands to indicate to others that they need help?",

choices:["A: Over the eyes", "B: Around the throat", "C: On the knees", "D: On the hips"],
correctAnswer:"B: Around the throat",

image:"<img: src='../assets/images/jeopardy.png' class='cashMoney'>"]
Here is how I'm calling the image:
Mã:
function playerWin() {
    var image = questions[questionTracker].image;
    $("#gameShow").html(image);
    $("#gameShow").html("<p>You got it right!</p>");
}
I also tried appending the image to a Div through its own function
Mã:
function displayImage() {
    var image = questions[questionTracker].image;
    $("#gameShow").append("<images>");
}
The image should show up with the
tag, but it does not.
Very new to all this. Any help greatly appreciated! Sorry If I didn't format the question correctly. It looks fine on the editor but loses the indentation when I post. :/
 

Admin

Administrator
Thành viên BQT
#2
Your image isn't working because of the invalid HTML:
Mã:
<img src: '...'>
There shouldn't be a colon. Replace this line in your array:
Mã:
image:"<img: src='../assets/images/jeopardy.png' class='cashMoney'>"]
With this line:
Mã:
image:"<img src='../assets/images/jeopardy.png' class='cashMoney'>"];
And your problem will be fixed.
 

Từ khóa phổ biến

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top