JSFiddle - React, Tailwind, and code Playground

by ArtyomShegeda

HTML

<p>Click the button to create.</p>

<div id="myDIV">
A DIV element
</div>

<button onclick="insertMessage()">Try it</button>

CSS

#myDIV {
    border: 1px solid black;
    margin-bottom: 10px;
    padding:10px;
}

JavaScript

function insertMessage(msg) {
  var tlkio = document.createElement("div");
  tlkio.style.width = "100%";
  tlkio.style.height = "400px";
  tlkio.id = "tlkio";
  tlkio.setAttribute('data-channel', 'regerhtrh');
  tlkio.setAttribute('data-theme', 'theme--night');

  var tlkScript = document.createElement("script");
  tlkScript.src = 'https://tlk.io/embed.js';
  tlkScript.type = 'text/javascript';
  tlkScript.onload = function(){
    var evt = document.createEvent('Event');  
    evt.initEvent('load', false, false);  
    window.dispatchEvent(evt);
  }
  tlkScript.async = true;

	document.getElementById('myDIV').insertBefore(tlkio, null);
 	document.getElementById('myDIV').insertBefore(tlkScript, null);
}