Untitled
unknown
plain_text
3 years ago
1.1 kB
11
Indexable
<!DOCTYPE html>
<html>
<head>
<title>Info Texts with Copy Button</title>
<style>
.container {
display: flex;
align-items: center;
}
.info-text {
margin-right: 10px;
}
.copy-button {
padding: 5px 10px;
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
}
</style>
</head>
<body>
<div class="container">
<p class="info-text">Info Text 1</p>
<button class="copy-button" onclick="copyToClipboard('info1')">Copy</button>
</div>
<div class="container">
<p class="info-text">Info Text 2</p>
<button class="copy-button" onclick="copyToClipboard('info2')">Copy</button>
</div>
<script>
function copyToClipboard(text) {
var tempInput = document.createElement("input");
tempInput.value = text;
document.body.appendChild(tempInput);
tempInput.select();
document.execCommand("copy");
document.body.removeChild(tempInput);
alert("Copied to clipboard: " + text);
}
</script>
</body>
</html>Editor is loading...