JSFiddle - React, Tailwind, and code Playground

by kurotanshi

HTML

<input type="checkbox" name="test" id="chkTest" /> 
<span id="temp">asdf</span>

JavaScript

$('#chkTest').click(function() {
    if (this.checked) {
        $('#temp').replaceWith('<input type="text" id="temp" value="' + $('#temp').html() + '" />');
    }
    else {
        $('#temp').replaceWith('<span id="temp">' + $('#temp').val() + '</span>');
    }
});