JSFiddle - React, Tailwind, and code Playground
HTML
<div id="myarea"></div>
JavaScript
$(document).ready(function () {
var hider = null;
var onetxt = $('<input type="text" />');
var Input1 = $('<input type="text" />');
var redDiv = $('<div>', {
tabindex: "5",
style: "width:200px;height:200px;background:red; display:none;",
text: 'test',
html: "<br /><br />"
}).append(Input1);
function hideRed () {
if (!onetxt.is(':focus') && !Input1.is(':focus') && !redDiv.is(':focus')) {
hider = setTimeout(function () {redDiv.hide();}, 10);
}
}
function showRed () {
if (hider !== null) {
clearTimeout(hider);
hider = null;
}
redDiv.show();
}
onetxt.focusin(showRed);
Input1.focusin(showRed);
redDiv.focusin(showRed);
redDiv.blur(hideRed);
Input1.blur(hideRed);
onetxt.blur(hideRed);
$('#myarea').after(onetxt, redDiv);
});