I am able to copy text in <textarea>
in this example. But after I simplify that code to the following one:
$('textarea').mouseout(function(){
$('textarea').blur();
});
$('textarea').mouseover(function(){
$(this).focus();
$(this).select();
document.execCommand('copy');
});
textarea {
margin-left: 15px;
margin-right: 15px;
width: 200px;
height: 17.5px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
BLABLABLA<textarea>Hover me, I am special!</textarea>BLABLABLA<br/>
<input placeholder="Paste me here!"></input>
I can select the text in that <textarea>
but not copy the text. I tried:
$(this)[0].execCommand('copy');
$(this).execCommand('copy');
this.execCommand('copy');
document.execCommand('copy');
Please help me. Thanks.