14. Membuat Sebuah Tombol Copy & Paste Manual

Hello everyone!

Kode di bawah ini bisa kalian implementasikan di widget HTML yang ada di Elementor atau di manapun kalian mau, selagi works.

HTML Code

				
					<!DOCTYPE html>

<html>
<body>
<input type="text" value="ESTEHCLOUD" id="myInput">
<button onclick="myFunction()">Copy text</button>

<script>
function myFunction() {

  // Get the text field
  var copyText = document.getElementById("myInput");

  // Select the text field
  copyText.select();

  copyText.setSelectionRange(0, 99999); // For mobile devices


  // Copy the text inside the text field
  navigator.clipboard.writeText(copyText.value);

  // Alert the copied text
  alert("Copied the text: " + copyText.value);

}
</script>
</body>
</html>
				
			

Preview:

Semoga bermanfaat dan selamat mencoba!

Shopping Cart
Scroll to Top