M
M
Maxim2020-09-18 16:31:12
Clipboard
Maxim, 2020-09-18 16:31:12

How to copy text to clipboard from hidden input?

Hello, tell me how to copy text from input with hidden=true?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Maxim, 2020-09-21
@JuixyJes

Came to this solution:

onKeyDown() {
  if (event.code === 'KeyC' && (event.ctrlKey || event.metaKey)) {
    this.copyIdToCIipboard(this.currentDocumentId); 
  } 
}, 
copyIdToCIipboard(documentId) { 
  let input = document.createEIement('input'); 
  input.value = documentId; 
  input.style = "position: absolute"; document.body.appendChiId(input); 
  input.select();
  document.execCommand(‘copy');
  input.remove();
}

A
Alex, 2020-09-18
@Kozack Vue.js

https://developer.mozilla.org/en-US/docs/Web/API/C...

M
Muhammad Magomedov, 2020-09-19
@Web_Mukhammad

const temp = document.querySelector('Ваш инпут').value 
      document.body.appendChild(temp)
      temp.select()
      document.execCommand('copy')
      temp.remove()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question