JSFiddle - React, Tailwind, and code Playground

by 8ogdan

HTML

<div class="post-content">
    <div id="post-inner-content">
        <p>Users comment will go here</p>
    </div><!-- .post-inner-content -->
    <a href="#" id="edit-post">Edit Post</a>
    <div id="edit-post-area">
        <textarea></textarea>
    </div><!-- .edit-post-area -->
</div>

JavaScript

$("#edit-post").click(function() {
    //Get the text
    var text = $("#post-inner-content").text()
    
    //Create a text area selector (container, rather)
    var textarea = $("#edit-post-area");

    //Give the textarea a value
    $("textarea", textarea).val(text);

    //Show it
    textarea.show();
});