jQuery中push与通过index添加的比较
来源:互联网 发布:北京联通网络测速 编辑:程序博客网 时间:2024/06/08 13:22
<style type="text/css">
.mtop10{margin-top:10px;}
.lt400{float:left;width:400px;}
</style>
<script type="text/javascript">
$(function(){
push();
index();
});
function push() {
$("#push").unbind("click").bind("click", function () {
$("#start1").val(new Date().getMinutes().toString() + " " + new Date().getSeconds().toString() + " " + new Date().getMilliseconds().toString());
var a = [];
for (var i = 0; i < 100000; i++) {
a.push(i);
}
$("#end1").val(new Date().getMinutes().toString() + " " + new Date().getSeconds().toString() + " " + new Date().getMilliseconds().toString());
});
}
function index() {
$("#index").unbind("click").bind("click", function () {
$("#start2").val(new Date().getMinutes().toString() + " " + new Date().getSeconds().toString() + " " + new Date().getMilliseconds().toString());
var a = [];
for (var i = 0; i < 100000; i++) {
a[a.length] = i;
}
$("#end2").val(new Date().getMinutes().toString() + " " + new Date().getSeconds().toString() + " " + new Date().getMilliseconds().toString());
});
}
</script>
<div class="mtop10">
<div class="lt400">
<div><input id="push" type="button" value="方法一" /></div>
<div><input id="start1" type="text" />(分 秒 毫秒)</div>
<div><input id="end1" type="text" />(分 秒 毫秒)</div>
</div>
<div class="lt400">
<div><input id="index" type="button" value="方法二" /></div>
<div><input id="start2" type="text" />(分 秒 毫秒)</div>
<div><input id="end2" type="text" />(分 秒 毫秒)</div>
</div>
</div>
--------------------------
比较之后的效果图:
当插入很多条数据的时候尽量用index进行插入的好。
- jQuery中push与通过index添加的比较
- JQuery的数组对象中通过[index]和.eq(index);没有.value或.val()
- jquery中push()的用法
- jquery中parent()与parents()的比较
- JQuery中css与attr的比较
- jquery中push(),unshift(),splice() ,concat(),pop(),shift(),slice()等的用法(数组添加元素)
- jquery中push(),unshift(),splice() ,concat(),pop(),shift(),slice()等的用法(数组添加元素)
- jQuery中 index() 方法的使用
- jquery中index()方法的使用
- 原生JS添加节点方法与jQuery添加节点方法的比较及总结
- 关于push与unshift的区别与比较
- android adb push 与 adb install的比较
- android adb push 与 adb install的比较
- Array的push与unshift方法性能比较分析
- JQuery中关于jquery.js与jquery.min.js的比较
- javascript中.push()与.concat()的区别
- Jquery与dom的比较
- ExtJs与jQuery的比较
- 判断字符串是否为纯数字
- 如何理解C语言中的typedef
- 热爆炸宇宙的误区谭
- 没有找到MFC80D.DLL的解决方法
- expect spawn、linux expect 用法小记
- jQuery中push与通过index添加的比较
- 如何理解C语言中的typedef
- GCC基础
- SQL数据库置疑修复
- 常见JAVA基础面试题3
- 年假計算方式
- tomcat启动时的两个批处理脚本详解
- JSP生成彩色验证码
- Log4j日志文件相对路径