<!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> 捕捉模式从DOM最顶层一直到最后一层,冒泡正好相反,具体运行以下实例测试.<!DOCTYPE html> <html> <head> <title>捕捉和冒泡</title> <meta charset="...
<form action="save.php" method="post" target="nm_iframe"> &nbs...
开发需求如下,商品下单后需要指定送到日期:送达日期为周一 周三 周六 ,如果今天周一,用户选择周一即为下一周周一。代码如下:<html> <head> <meta charset="utf-8"> <title>...
二期项目中生成的简历二维码是使用canvs生成的,微信浏览器中不能识别二维码,只能扫码。懒的换phpqrcode,于是转canvs。//设置一个url var url = "{yun:}$config.sy_weburl{/yun}/mingli/index....
//我们创建每个函数默认都有一个prototype(原型)属性,这个属性是一个对象 //1.我是普通的构造方法,我的属性叫实例属性,我的方法叫实例方法 /* function Box(name,age){ this.name=name; this.age=age; this.run...
//字面量的形式创建原型对象 /* function Box(){} Box.prototype={ 'name':'gao', age:23, fun:function(){ return this.name+'--'+...