Skip to content
Advertisement

Copy to clipboard javascript (no jQuery)

I have an Angular 9 app which I need to get a copy to clipboard of url copied when clicked. This is what I have so far:

It copies but not on first attempt only on second attempt is it consoled. Then the clicks stack up so the third click it shows it was clicked 3 times. Why? What am I doing wrong here?

JavaScript

Advertisement

Answer

I was able to resolve this issue by using the code below:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement