Replace table date with an image | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Replace table date with an image

How can I amend the below code to replace with image instead of text. As currently the text "<img src='images/image"+(getRand())+".png'/>" appeared instead of an image. $('#choices td').click(function (){ (this).replaceWith("<img src='images/image"+(getRand())+".png'/>"); });

25th Feb 2020, 5:00 AM
SWL
3 Answers
+ 2
try this `images/image${(getRand())}.png` then get the image element, set the src to the string i shown above
25th Feb 2020, 6:28 AM
Taste
Taste - avatar
+ 2
I tried to figure out the element of #choices id", i guess it should be a table. And getRand() should be getting a random from from image numbers. Here is the demo of replaceWith function https://code.sololearn.com/WmkkvZH7ucjf/?ref=app
25th Feb 2020, 10:36 AM
Calviղ
Calviղ - avatar
0
SWL you should show us how does the element #choices presented on html with text. And where is the getRand() function, what does the function do?
25th Feb 2020, 6:29 AM
Calviղ
Calviղ - avatar