js对象爆炸的简单示例
来源:互联网 发布:用ps做淘宝店长图 编辑:程序博客网 时间:2024/05/16 08:09
<h1>文件上传与对象爆炸的简单案例</h1> <script> var id = 0; startUpload = function( uploadType, files ){ for( var i = 0, file; file = files[ i++ ]; ){ var uploadObj = new Upload( uploadType, file.fileName, file.fileSize ); uploadObj.init( id++ ); } }; var Upload = function( uploadType, fileName, fileSize ){ this.uploadType = uploadType; this.fileName = fileName; this.fileSize = fileSize; this.dom = null; }; Upload.prototype.init = function( id ){ var that = this; this.id = id; this.dom = document.createElement("div"); this.dom.innerHTML = '<span>文件名称:' + this.fileName + ', 文件大小:' + this.fileSize + '</span>' + '<button class="delFile">删除</button>'; this.dom.querySelector( '.delFile' ).onclick = function(){ that.delFile(); }; document.body.appendChild( this.dom ); }; Upload.prototype.delFile = function(){ if( this.fileSize < 3000 ){ return this.dom.parentNode.removeChild( this.dom ); }; if( confirm( "确定要删除该文件么?" + this.fileName )){ return this.dom.parentNode.removeChild( this.dom ); } }; startUpload( "plugin", [ { fileName: "1.txt", fileSize: 1000 }, { fileName: "2.txt", fileSize: 2000 }, { fileName: "3.txt", fileSize: 5000 } ]) </script>
0 0
- js对象爆炸的简单示例
- 简单的函数对象示例
- 匿名对象的简单示例
- 时间轴的实现(简单到爆炸)
- js 面向对象的语法示例
- jQuery 克隆对象的简单示例
- XMLHttpRequest对象的一个简单运用示例
- js中button事件的简单示例
- 简单的JS下拉菜单示例代码
- JS 简单的轮播特效示例
- 构建一个简单的Three.js 示例
- Node.js操作Redis的简单示例
- node.js简单示例
- Unity3D 粒子系统实现一个简单的爆炸效果
- JS获取对象代码示例
- js中创建对象的几种方式示例介绍
- 02.JS遍历对象属性的方法示例
- 简单解析url参数的js对象。
- rsyslog 基本结构
- 启动 Eclipse提示“Failed to load the JNI shared library jvm.dll”
- ASP.NET AJAX Advance Tips & Tricks (3) JavaScript与Tab的交互
- 《Android Studio项目结构(一)——目录列表》
- ASP.NET AJAX Advance Tips & Tricks (4) ASP.NET AJAX Performance Improvement
- js对象爆炸的简单示例
- 【学习笔记】系列十五:Ant单元测试JUnit
- org.apache.commons.lang.StringUtils源码
- Python自动化面试必备 之 你真明白装饰器么?
- Android 系统架构
- ssh公私钥正确的情况下免密登录失败原因
- python连接sql server并执行查询操作
- 设计模式-中介者模式
- Plugin with id 'me.tatarka.retrolambda' not found.