JSFiddle - React, Tailwind, and code Playground

by mikkelbreum

HTML

<p>Click here, then use tab key to focus textareas without clicking.<BR>Then try clicking.<br>Demonstrates a problem where the etxt does not get selected on focus, and also it seems that the click event is not always firing (in which case focus actually causes the text to be selected).</p><br>
<textarea class="automarkup" style="width=:200px;height:140px;">Here is some text that should get selected..</textarea><br><textarea class="automarkup" style="width=:200px;height:140px;">Here is some text that should get selected..</textarea>

JavaScript

$('textarea.automarkup')
    .mouseup(function(e){
        // fixes safari/chrome problem
        e.preventDefault();
    })
    .focus(function(e){
        mytxt = $(this).text();
        $(this).text( mytxt + "\n event fired: " + e.type );
        $(this).select();
        
    })
    .click(function(e){
        mytxt = $(this).text();
        $(this).text( mytxt + "\n event fired: " + e.type );
        $(this).select();
    });