4
4
4eloBek2015-09-25 21:38:21
JavaScript
4eloBek, 2015-09-25 21:38:21

How to paste text from clipboard on click?

There is, for example, the following code:

html:

<div id="txt" contenteditable="true"></div>
<button id="btn">Click</button>

css:
#txt {
    height: 30px;
    border: 1px dashed grey;
}

js:
$('#btn').on('click',function() {
  var pastetext = clipboardData.getData("text/html");
    $('#txt').html(pastetext);
});

How to paste text from clipboard on button click?

PS But, basically, I need to put the text from the buffer into a variable)))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Taratin, 2015-09-25
@4eloBek

No way.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question