I am getting this error when I will apply some jQuery code in my code.
It show me this error: Failed to execute ‘setSelectionRange’ on ‘HTMLInputElement’: The input element’s type (‘hidden’) does not support selection
I am following this code:
<script type="text/javascript"> function copyToClipboard(elem) { var isInput = elem.tagName === "INPUT" || elem.tagName === "TEXTAREA"; if (isInput) { target = elem; } // select the content var currentFocus = document.activeElement; target.focus(); target.setSelectionRange(0, target.value.length); // copy the selection var succeed; try { succeed = document.execCommand("copy"); } catch(e) { succeed = false; } return succeed; } </script>
This error showing you because your input type have hidden type=”hidden”
You need to change this and get input type=”text” or Apply “readonly”
If you HTML input field like this:
<input type="hidden" name="">
Replace it by this code:
<input type="text" name="">
or
<input type="text" name="" readonly>
Question and answer is powered by AnsPress.io