windows 10 pro office 2019 pro office 365 pro windows 10 home windows 10 enterprise office 2019 home and business office 2016 pro windows 10 education visio 2019 microsoft project 2019 microsoft project 2016 visio professional 2016 windows server 2012 windows server 2016 windows server 2019 Betriebssysteme office software windows server https://softhier.com/ instagram takipçi instagram beğeni instagram görüntüleme instagram otomatik beğeni facebook beğeni facebook sayfa beğenisi facebook takipçi twitter takipçi twitter beğeni twitter retweet youtube izlenme youtube abone instagram

Javascript: body.append(content) is not rendered as html

Asked By: Anonymous

I am building a little piece of html document using javascript templates. const button in the code below is my template. As you can see I replace some content using replace. const button become <button>label</button> and that’s fine.

const button = `<button>{try}</button>`;
const newButton = button.replace('{try}', 'label');
const body = document.querySelector('body');

Now I want to append my bew button inside body tag.

body.append(newButton);

It works BUT when I refresh browser I see "<button>label</button>" but I want the rendered version of this html and now I cant see a button but a string <button>.... How can I render this button?


Solution

Answered By: Anonymous

How about using insertAdjacentHTML?

_x000D_

_x000D_

const button = `<button>{try}</button>`;
document.body.insertAdjacentHTML(`beforeend`, button.replace('{try}', 'label'));

_x000D_

_x000D_

x000D

techinplanet staff


Windows 10 Kaufen Windows 10 Pro Office 2019 Kaufen Office 365 Lizenz Windows 10 Home Lizenz Office 2019 Home Business Kaufen windows office 365 satın al follower kaufen instagram follower kaufen porno