<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>点击复制</title>
</head>
<body>
推荐码 : <span id="copy-text">123456</span>
<a href="javascript:;" onclick="copyToClipboard('copy-text')" class="copy-btn">点击复制</a>
<script type="text/javascript">
function copyToClipboard(elementId) {
var aux = document.createElement("input");
var content = document.getElementById(elementId).innerHTML || document.getElementById(elementId).value;
aux.setAttribute("value", content);
document.body.appendChild(aux);
aux.select();
document.execCommand("copy");
document.body.removeChild(aux);
console.log('复制成功!直接粘贴即可');
}
</script>
</body>
</html> <!DOCTYPE html> <html> <head> <title>捕捉和冒泡</title> <meta charset="utf-8"> </head> <bo...
<!doctype html> <html> <head> <meta charset="utf-8"> <title>无标题文档</title> <script type...
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>获取mac地址</title> </head&g...
//字面量的形式创建原型对象 /* function Box(){} Box.prototype={ 'name':'gao', age:23, fun:function(){ return this.name+'--'+...
rem原理和简介(1).字体单位单位的值是根据html根元素大小而定,同样可以作为宽度高度单位(2).适配原理将px替换为rem,动态修改html的font-size适配(3).单位1rem=16px,why? F12中1rem在computed中font-size属性中会显示为font-size:...
在es5的时候变量只能通过+号拼接,es6种允许将变量放在大括号之中。有点类似php和c#对字符串的操作。 <script type="text/javascript"> &n...