0

I am copying text in Windows. And I need to paste my copy by clicking on a button with JQuery or Javascript.

I Search but only find a copy with jquery.

Hp_issei
  • 550
  • 6
  • 16
Ca ca
  • 65
  • 1
  • 8

2 Answers2

0

You can't do it with jQuery, but you can use javascript with the navigator.clipboard API:

navigator.clipboard.readText()
  .then(text => {
     $('#myTextBox').val(text);
  });
Koby Douek
  • 14,709
  • 15
  • 58
  • 84
  • 1
    Possible duplicate of [Get current clipboard content?](https://stackoverflow.com/questions/6413036/get-current-clipboard-content) – Hp_issei Jan 17 '19 at 06:27
0

try this one, but its only working in IE.

function Copy() {
     if(window.clipboardData) {
       window.clipboardData.clearData();
       window.clipboardData.setData("Text", document.getElementById('txtacpy').value);
     } 
    }
    function paste() {
     if(window.clipboardData) {   
       document.getElementById('txtapaste').value = window.clipboardData.getData("Text");
     } 
}
 <a href="javascript:Copy();">Copy</a>
    <br />
    <input type="text" name="txtacpy" id ="txtacpy"/>
    <br />
    <a href="javascript:paste();">Paste</a>
    <br />
    <input type="text" name="txtapaste"  id="txtapaste"/>
Prabhat Sinha
  • 1,499
  • 17
  • 27