Uncaught TypeError: text.select is not a function
I ran into this problem today and felt frustrated just as you when the marked answer didn't work for me.
After some additional thinking i realised my problem was trying to paste into paragraph element <p></p>
.
When I changed it to textarea it worked well.
So you indeed had a problem with the access to the array but when you finally got to the specific element you should have made sure its an editable element.
Good luck!
getElementsByClassName
returns a HTMLCollection
of found elements not an individual element. A HTMLCollection indeed does not have a select
function.
You probably want the first element in the collection
var text = document.getElementsByClassName('js-text');
text[0].select();