Code to copy text once clicking a button
- by admin
- 0
Using javascript define a fucntion:
function copy(url) {
var inputing_var = document.createElement(“input”);
inputing_var.setAttribute(“value”, url);
document.body.appendChild(inputing_var);
inputing_var.select();
document.execCommand(“copy”);
document.body.removeChild(inputing_var);
}
Use below code to create buttons:
<?php $copylinks=”Hello”; ?>
<button onclick=”copy(‘<?php echo $copylinks; ?>’);”>Copylink</button>
Using javascript define a fucntion: function copy(url) { var inputing_var = document.createElement(“input”); inputing_var.setAttribute(“value”, url); document.body.appendChild(inputing_var); inputing_var.select(); document.execCommand(“copy”); document.body.removeChild(inputing_var); } Use below code to create buttons: <?php $copylinks=”Hello”; ?> <button onclick=”copy(‘<?php echo $copylinks; ?>’);”>Copylink</button>
Using javascript define a fucntion: function copy(url) { var inputing_var = document.createElement(“input”); inputing_var.setAttribute(“value”, url); document.body.appendChild(inputing_var); inputing_var.select(); document.execCommand(“copy”); document.body.removeChild(inputing_var); } Use below code to create buttons: <?php $copylinks=”Hello”; ?> <button onclick=”copy(‘<?php echo $copylinks; ?>’);”>Copylink</button>