公用代码学习室

		function copy(copyContent, ele) {
			let textarea = document.createElement("textarea");
			ele.appendChild(textarea); 
			textarea.value = copyContent;
			textarea.focus();
			if (textarea.setSelectionRange) textarea.setSelectionRange(0, textarea.value.length); //获取光标起始位置到结束位置
			else textarea.select();
			try {
				document.execCommand("copy"); //执行复制
			} catch(eo) {}
			ele.removeChild(textarea); //删除元素
			ele.focus();
			$.growl.notice({
				title: "複製成功!",
				message: "已複製到粘貼板",
				duration: 5000
			});
		}
		


本网站仅供IT学习:
粤ICP备18092608号-1