JSFiddle - React, Tailwind, and code Playground
by lutskboy
HTML
<div class="full">
<h1>Резюме 54</h1>
<div class="descr">описание. текст текст текст</div>
<div class="item">
<div class="itemi">ФИО:</div>
<div class="itemi">иван иванов</div>
</div>
<div class="item">
<div class="itemi">ОБРАЗОВАНИЕ:</div>
<div class="itemi">высшее</div>
</div>
<div class="item">
<div class="itemi">ВОЗРАСТ:</div>
<div class="itemi">27 лет</div>
</div>
</div>
<button id="copy">Copy</button>
CSS
.item{display:flex;}
JavaScript
// Copies a string to the clipboard. Must be called from within an event handler such as click.
// May return false if it failed, but this is not always
// possible. Browser support for Chrome 43+, Firefox 42+, Edge and IE 10+.
// No Safari support, as of (Nov. 2015). Returns false.
// IE: The clipboard feature may be disabled by an adminstrator. By default a prompt is
// shown the first time the clipboard is used (per session).
function copyToClipboard(text) {
if (window.clipboardData && window.clipboardData.setData) {
// IE specific code path to prevent textarea being shown while dialog is visible.
return clipboardData.setData("Text", text);
} else if (document.queryCommandSupported && document.queryCommandSupported("copy")) {
var textarea = document.createElement("textarea");
textarea.textContent = text;
textarea.style.position = "fixed"; // Prevent scrolling to bottom of page in MS Edge.
document.body.appendChild(textarea);
textarea.select();
try {
return document.execCommand("copy"); // Security exception may be thrown by some browsers.
} catch (ex) {
console.warn("Copy to clipboard failed.", ex);
return false;
} finally {
document.body.removeChild(textarea);
}
}
}
document.querySelector("#copy").onclick = function() {
var result = copyToClipboard($('.full').text());
console.log("copied?", result);
};