Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

html tag displayed in browser instead rendering it

I am using this https://codepen.io/toschivictor/pen/JjNZjEj

I need to replace icons with images,

so I replaced these icons

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

const items = [
    '🍭',
    '❌',
    '⛄️',
    'πŸ¦„',
    '🍌',
    'πŸ’©',
    'πŸ‘»',
    '😻',
    'πŸ’΅',
    '🀑',    
    'πŸ¦–',
    '🍎',
    'πŸ˜‚',
    'πŸ–•',
  ];

with below code,

const items = [
    '<img src="image.jpg">',
    '<img src="image.jpg">',
    '<img src="image.jpg">',
    '<img src="image.jpg">',
    '<img src="image.jpg">',
    '<img src="image.jpg">',
    '<img src="image.jpg">',
    '<img src="image.jpg">',
    '<img src="image.jpg">',
];

However it is displaying the tag itself instead of showing image,

which tag or which style or which js function causing this?

>Solution :

Hi @arun

You need to append these tag as HTML elements, not as text.

You need that:-

box.innerHTML = pool[i];

not that:-

box.textContent = pool[i];

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading