Question: text is not selected in js tried all methods in. `select()` and `btn.select()` in not selecting the text in textbox

```js
        var in = document.getElementById("in");
        var btn = document.getElementById("btn");

        btn.onclick() = function(){
            in.focus();
            in.select();
            in.setSelectionRange(0,9999);
             document.execCommand("copy");
        };
```

```html
    <body>
        <input id="in" type="text">
        <button id="btn" >Copy </button>
    </body>
```

Answer: 
`in` is a reserved key in javascript so cant use it and you have to remove `()` after the onclick when you want to assign it to value.

```js
            var inputField = document.getElementById("in");
            var btn = document.getElementById("btn");

            btn.onclick = function(){
                inputField.focus();
                inputField.select();

                inputField.setSelectionRange(0, 99999)
                document.execCommand("copy");
            };

            var linkTag = document.getElementById("link");
            var btnLink = document.getElementById("btn-link");

        btnLink .onclick = function(){
            const range = document.createRange();
            range.selectNode(linkTag );
            const selection = window.getSelection();
            selection.removeAllRanges();
            selection.addRange(range);

            document.execCommand('copy');
        };
```

```html
        <body>
            <div>
                <input id="in" type="text">
                 <button id="btn" >Copy </button>
             </div>
            <div>
                 <a href="google.com" id="link">google.com</a>
                 <button id="btn-link" >Copy </button>
             </div>
        </body>
```
There are 2 issues with your code:

1. `in` is a reserved word in js, so you can't use it as a variable name.
2. You're wrong at setting onclick event for button

```
btn.onclick() = function(){ // there should not have '()' after onclick
...

```

You should check the error on console when code executed.