JSFiddle - React, Tailwind, and code Playground

by TrueBlueAussie

HTML

<input type="text" value="one" />
<br/>
<input type="text" value="two" />
<br/>
<select>
    <option value="1">1</option>
    <option value="1">2</option>
    <option value="1">3</option>
</select>
<input type="text" value="three" />
<button>A Button</button>
<br/>
<p>Previous focus:</p>
<div id="prev"></div>

JavaScript

// prime with empty jQuery object
    window.prevFocus = $();
    // Catch any bubbling focusin events (focus does not bubble)
    $(document).on('focusin', ':input', function () {
        // Test: Show the previous value/text so we know it works!
        $("#prev").html(prevFocus.val() || prevFocus.text());
        // Save the previously clicked value for later
        window.prevFocus = $(this);
    });