<!DOCTYPE html>
<html>
<head>
<title>Kotak dengan Fitur Copy Code</title>
<style>
.container {
width: 80%;
margin: 0 auto;
padding: 20px;
border: 1px solid black;
}
.code-box {
position: relative;
margin-top: 20px;
}
.code-box textarea {
width: 100%;
height: 200px;
padding: 10px;
border: none;
background-color: #f2f2f2;
resize: none;
}
.code-box button {
position: absolute;
top: 10px;
right: 10px;
padding: 10px;
border: none;
background-color: #4CAF50;
color: white;
cursor: pointer;
}
</style>
</head>
<body>
<div class="container">
<h1>kode Kotak dengan Fitur Copy Code</h1>
<p>untuk membuat kotak script atau kode di dalam kotak terdapat fitur copy</p>
<div class="code-box">
<textarea id="myTextarea" readonly> masukan kode di sini
</textarea>
<button onclick="copyToClipboard()">Copy</button>
</div>
</div>
<script>
function copyToClipboard() {
var copyText = document.getElementById("myTextarea");
copyText.select();
copyText.setSelectionRange(0, 99999);
document.execCommand("copy");
alert("Kode berhasil dicopy!");
}
</script>
</body>
</html>
kode Kotak dengan Fitur Copy Code
untuk membuat kotak script atau kode di dalam kotak terdapat fitur copy