JSFiddle - React, Tailwind, and code Playground

by metulev

HTML

<span id="mydiv" contenteditable>
editable follows:
</span>

CSS

#someid{
 outline:1px solid #ccc;
}

JavaScript

function AppendSpan()
{
    $('#mydiv').append('<span id="someid" contenteditable="true">Some TExt</span>');
    //Then I want to handle the keypress event on the inserted span
    $('#mydiv').keypress(function(event){alert(this.id);});
}

AppendSpan();