Really like this - excellent work!
If i leave the input as it works as expected.
I'd like to use it with a hidden input, but when I add type="hidden" the text no longer gets copied.
Tried it with display:none but had the same results.
I can style the input so the input cannot be seen but I'd rather be able to use a hidden input, if possible.
Hey @168tickets,
You can either use the readonly attribute on your input or the data-clipboard-text option.
If using an <input type="hidden"> is the only option, then you could go with:
new Clipboard('.btn', {
text: function() {
return document.querySelector('input[type=hidden]').value;
}
});
Hope that helps @168tickets, thanks!
Sure did! I used data-clipboard-text option so I didn't need the hidden input. Works great! Thanks so much!
I can't seem to get this to work with <input type="hidden" readonly="true" id="inputID" data-clipboard-text="VALUE.">.
Hey,
same problem here, can't make it work with hidden :(((
Finally used : data-clipboard-text="'.$url.'"
works!
Most helpful comment
If using an
<input type="hidden">is the only option, then you could go with: