A read-only assignment is very different from a disconnected one, and their location is very different.
To select or even copy text from disabled input, you can follow the Andy E suggestion
Or, as in my case, so that the button (input group-attached) is associated with the input text. And then at the click of a button:
- enable text input
- choose or focus or what do you want to do
- disconnect again
Like this:
$('#btnCopy').click(function(){ $('#txtInputDisabled').removeAttr('disabled'); $('#txtInputDisabled').select(); document.execCommand("copy"); $('#txtInputDisabled').attr('disabled','disabled'); });
Full example no jsfiddle
dchang
source share