Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
40
rated 0 times [  44] [ 4]  / answers: 1 / hits: 19652  / 7 Years ago, mon, december 4, 2017, 12:00:00

Hello Guys I want to copy input value yeah on button click But nothing work. Please Help!!



<script>
function copyToClipboard(element) {
var $temp = $(<input>);
$(body).append($temp);
$temp.val($(element).text()).select();
document.execCommand(copy);
$temp.remove();
}
</script>

<input type=text class=form-control name=myvalue id=myvalue value=YEAH readonly />

<button class=btn btn-primary btn-block onclick=copyToClipboard('#myvalue')>Copy myvalue</button>

More From » jquery

 Answers
10



function copyToClipboard() {
var textBox = document.getElementById(myvalue);
textBox.select();
document.execCommand(copy);
}

<input type=text class=form-control name=myvalue  id=myvalue value=YEAH readonly  />

<button class=btn btn-primary btn-block onclick=copyToClipboard()>Copy myvalue</button>




[#55769] Thursday, November 30, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kamronr

Total Points: 749
Total Questions: 110
Total Answers: 122

Location: Dominica
Member since Sat, Nov 5, 2022
2 Years ago
kamronr questions
Mon, Dec 21, 20, 00:00, 3 Years ago
Fri, Oct 16, 20, 00:00, 4 Years ago
Sat, Oct 3, 20, 00:00, 4 Years ago
Sun, Jul 28, 19, 00:00, 5 Years ago
;