1<html>
2 <input type="text" value="Hello world"(Can be of your choice) id="myInput"(id is the name of the text, you can change it later)
3<button onclick="Hello()">Copy Text</button>
4
5<script>
6 function Hello() {
7 var copyText = document.getElementById('myInput')
8 copyText.select();
9 document.execCommand('copy')
10 console.log('Copied Text')
11}
12</script>
1$(document).ready(function(){
2 $("#ewefmwefmp").click(function(){
3 //alert()
4 var copyText = document.getElementById("myInput");
5 copyText.select();
6 copyText.setSelectionRange(0, 99999)
7 document.execCommand("copy");
8 alert("Copied the text: " + copyText.value);
9
10 });
11});
1<!DOCTYPE html>
2<html>
3 <head>
4 <script>
5 function paste() {
6 var pasteText = document.querySelector("#text");
7 pasteText.focus();
8 document.execCommand("paste");
9
10 pasteText.value = pasteText.value + pasteText.value;
11 }
12 </script>
13 </head>
14 <body>
15 <input id="text">
16 <button onclick="paste()">Paste</button>
17 </body>
1<script>
2function copyToClipboard(element) {
3 var $temp = $("<input>");
4 $("body").append($temp);
5 $temp.val($(element).text()).select();
6 document.execCommand("copy");
7 $temp.remove();
8}
9</script>
10
11<p id="text">Hello</p>
12<button onclick="copyToClipboard('#text')"></button>