Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to copy text in the clipboard in js

<html>
  <input type="text" value="Hello world"(Can be of your choice) id="myInput"(id is the name of the text, you can change it later)
<button onclick="Hello()">Copy Text</button>

<script>
  function Hello() {
  var copyText = document.getElementById('myInput')
  copyText.select();
  document.execCommand('copy')
  console.log('Copied Text')
}
</script>
Comment

copy text to clipboard javascript without input

navigator.clipboard.writeText('the text')
Comment

js copy input value to clipboard

<input type="text" placeholder="Create Password" id="text" readonly>
<script>
  function copyPassword(){
    var copyText = document.getElementById('text')
    copyText.select()
    copyText.setSelectionRange(0, 999)
    document.execCommand("copy")
    console.log(copyText);
  }
</script>
Comment

PREVIOUS NEXT
Code Example
Javascript :: react native dimensions window vs screen 
Javascript :: react import css only for component 
Javascript :: discord.js arguments 
Javascript :: cypress ignore error 
Javascript :: nice react native shadow 
Javascript :: vue 3 computed getter setter 
Javascript :: javascript check if argument is passed 
Javascript :: jquery get radio button checked 
Javascript :: split date 
Javascript :: this keyword in javascript medium 
Javascript :: array to string javascript without commas 
Javascript :: remove property from object js 
Javascript :: how to add alternate image in img tag in react 
Javascript :: on click jquery 
Javascript :: express.static 
Javascript :: on function change body background image 
Javascript :: Jquery handle change event of file upload created dynamically 
Javascript :: change key in array of objects javascript 
Javascript :: angular 9 form value changes 
Javascript :: javascript .fill 
Javascript :: javascript pass object by value 
Javascript :: javascript sql 
Javascript :: jquery add multiple classes 
Javascript :: use regex to make sure it is a date 
Javascript :: convert decimal to binary javascript 
Javascript :: js remove seconds from time 
Javascript :: disable a button in javascript 
Javascript :: express js boilerplate 
Javascript :: jquery contains text 
Javascript :: angularjs download xml file 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =