当前位置:网站首页>Function: JS Click to copy content function

Function: JS Click to copy content function

2022-07-07 15:47:00 Sam young

Go straight to the code

/**  Copy content  */
export function handleCopy (value: string) {
    
	/**  Create a input Elements   By executing the selection input Inside value  perform copy command   that will do   then   Eliminate elements  */
  const dom = document.createElement('input')
  dom.value = value
  document.body.appendChild(dom)
  dom.select()
  document.execCommand('copy')
  dom.remove()
}
原网站

版权声明
本文为[Sam young]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130610295085.html