JSFiddle - React, Tailwind, and code Playground

by Norlihazmey Ghazali

HTML

<textarea>Some text</textarea>
<button type="button">Submit</button>

JavaScript

var lastFocus;

lastFocus = $("textarea");

lastFocus.focus();

$(document).click(function(e) {
    
    e.preventDefault();
    e.stopPropagation();
    
    if (lastFocus) {
        setTimeout(function() {lastFocus.focus()}, 10);
    }
    
    return(false);
});
    

$("button").click(function() {
    alert("submit using ajax")
});