@victorequena22/utiles
Version:
Utilidades para mi uso que pongo a dispocion
32 lines (31 loc) • 822 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.focusId = exports.portapapeles = void 0;
const portapapeles = (str) => {
// PASO 1
const el = document.createElement("textarea");
// PASO 2
el.value = str;
el.setAttribute("readonly", "");
// PASO 3
el.style.position = "absolute";
el.style.left = "-9999px";
document.body.appendChild(el);
// PASO 4
el.select();
// PASO 5
document.execCommand("copy");
// PASO 6
document.body.removeChild(el);
return str;
};
exports.portapapeles = portapapeles;
function focusId(id) {
setTimeout(() => {
const el = document.getElementById(id);
if (el !== null) {
el.focus();
}
}, 100);
}
exports.focusId = focusId;