var range = document.createRange(); range.selectNode(document.querySelector('#元素id')); var selection = window.getSelection(); if (selection.rangeCount > 0) selection.removeAllRanges(); selection.addRange(range); document.execCommand('copy');
标签:selection,前端,元素,一键,range,var,document,亦可 From: https://www.cnblogs.com/caijiqi190731/p/16936056.html