Uncaught TypeError: text.select is not a function
<p>I am trying to implement copy to clipboard feature using javascript which is meant to copy the text in the text area when the copy button is clicked by the user. This is the code from script which is meant to do this feature.</p>

<pre><code>var item = document.getElementsByClassName('js-copyBtn');

for(var i=0; i &lt; item.length; i++){
    item[i].addEventListener('click', function(event){

        var text = document.getElementsByClassName('js-text');
        text.select();

        try{
            var successful = document.execCommand('copy');
            var msg = successful ? 'successful' : 'unsuccessful';    
            console.log('Copy was ' + msg);  
       } catch(err) {  
         console.log('Oops, unable to copy');  
       }  
    });
}
</code></pre>

<p>However when i run this, i am getting an error on google chrome console saying <strong>Uncaught TypeError: text.select is not a function</strong>. I have also tested this on other browsers but getting the same result. Anyone else came across this problem ? </p>