Wednesday, November 28, 2018

Select and copy text from a react material ui TextField

For some reason I could not access the underlying input element, so  I added a hidden input element to the page, copied the textfield content to it and then copied it from there:

$('#copy').show();
$('#copy').focus();
$('#copy').val(this.state.input);
$('#copy').select();
document.execCommand('copy')
$('#copy').hide();

No comments:

Post a Comment