0
How do i make the in that code visible
6 odpowiedzi
+ 1
Code is messy, but from what I see you need add img element with src attribute
document.write("<span class='width:100%'>" + `<img width="100px" height="100px" src=${image[i]}>` + "</span>" + "\"");
And the problem you not getting your images, because the function is never called, although the image urls are not valid, so it won't show up even if you call the function and it will run properly.
Add this instead of img element you already have in your html document
<button onClick="getContent()" >Call the function</button>
+ 1
You put a variable as a string and forgot to uncomment this out:
document.write("<span class='width:100%'>" + "<img width='100px' height='100px' src="+image[i]+">" + "</span>" + "\"");
0
This is what you need to know.
https://www.sololearn.com/learning/2752/
https://www.w3schools.com/js/js_htmldom.asp
0
Check it now
https://code.sololearn.com/WWD297Dpu5K7/?ref=app
i did some changes but isn't still working
0
I'm not sure if it applies here, but there is no link to the JS in the HTML that I could see.
0
Sololearn playgound internally links the css and javascript tabs. But yes, you should properly link them in your actual code.
Perhaps you want to randomly display one of the four items in your contents and image arrays?
Except for the broken image link for image[3], maybe you want something like this:
https://code.sololearn.com/WosIcQYuOSeX/?ref=app