I have:
HTML code:
<div class="server-ip clearfix">
<p>
<i class="ion-ios-world"></i>
<span id="serv-1">play.minesuperior.com</span>
</p>
<a class="copy-action" href="#!" onclick="copyText('serv-1')">
<span class="copy-text">
<i class="ion-scissors"></i>
Copy
</span>
</a>
</div>
JS function:
function copyText(textToCopy) {
var copyText = document.getElementById(textToCopy).textContent;
console.log(copyText);
copyText.select();
document.execCommand("Copy");
alert("Copied the text: " + copyText);
}
I get error:
Uncaught TypeError: copyText.select is not a function
Why? In function I pass param: play.minesuperior.com
.
I tryied in console.log put param function and I get my text.