JSFiddle - React, Tailwind, and code Playground

by oscard

HTML

<div id="textField" contenteditable="true"></div>

CSS

#textField {
    width: 300px;
    border: 1px solid #ccc;
    min-height: 50px;
    margin-bottom: 20px;
}

#textViewer {
    width: 300px;
    border: 1px solid #ccc;
    height: 50px;
}

JavaScript

/********** Clear String *************/

var txt = document.getElementById("textField");
var viewer = document.getElementById("textViewer");

function getString() {
    var t = txt.innerText;
    console.log(t);
    
    console.log(t.split("\n"));
    return t;
}

function clearString() {
    txt.innerText = getString();
}

txt.onblur = clearString;