copyURL1(){
const links = document.getElementsByClassName("copylink" );`enter code here`
const range = document.createRange();
range.selectNode(links);
const selection = window.getSelection();
selection.removeAllRanges();
selection.addRange(range);
const successful = document.execCommand('copy');
}
I have written the code to copy the text from element but its showing the error Argument of type 'HTMLCollectionOf' is not assignable to parameter of type 'Node'. Type 'HTMLCollectionOf' is missing the following properties from type 'Node': baseURI, childNodes, firstChild, isConnected, and 46 more.
Change getElementsByClassName code, this might help.
const links = document.getElementsByClassName("copylink" ).item(0);
Ref: https://developer.mozilla.org/en-US/docs/Web/API/Range/selectNode