上一页 1 ··· 3 4 5 6 7 8 9 10 下一页
摘要: 1 // 函数传递参数 是 值传递 2 function addTen(num){ 3 num += 10; 4 return num; 5 } 6 7 var count = 20; 8 var result = addTen(count); 9 console.log(result); // 3010 console.log(count); // 20 count在addTen 里面是局部参数,不会改变外部的值11 12 //===========================... 阅读全文
posted @ 2013-10-09 14:09 楚玉 阅读(229) 评论(0) 推荐(0) 编辑
摘要: 1 ;(function(global){ 2 3 var G = {}; 4 G.LOG = (function(){ 5 log : 11; // log 不是 G.FUNC 的属性 外界不能访问 6 })(); 7 G.fail = function(){ 8 if( typeof need != "undefined"){ 9 console.log(11);10 }11 };1... 阅读全文
posted @ 2013-10-08 10:26 楚玉 阅读(167) 评论(0) 推荐(0) 编辑
摘要: 1 function multistep(steps, args, callback){ 2 var tasks = steps.concat(); 3 4 setTimeout(function(){ 5 var task = tasks.shift(); 6 7 task.apply(null, args || []); // call / aplly 第一个参数是 null或者undefined的时候指向window 或者 Global 8 9 if(tasks.leng... 阅读全文
posted @ 2013-09-30 10:44 楚玉 阅读(240) 评论(0) 推荐(0) 编辑
摘要: 1 // 用定时器处理数组 2 var items = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]; 3 4 function processArray(items, process, callback){ 5 var todo = items.concat(); // 克隆原数组 6 7 setTimeout(function(){ 8 process(todo.shift()); // 取得数组的下个元素并进行处理 9 10 /... 阅读全文
posted @ 2013-09-29 14:29 楚玉 阅读(767) 评论(0) 推荐(0) 编辑
摘要: 1 var sub = document.getElementById("sub");2 sub.setAttribute("disabled", "disabled"); // 兼容的3 sub.setAttribute("style", "position:absolute;left:100px;top:100px;"); // IE 7 不能设置成功4 5 // 以下为兼容方法: 6 var cssText = "position:absolute;left:100px;top: 阅读全文
posted @ 2013-09-27 10:55 楚玉 阅读(318) 评论(0) 推荐(0) 编辑
摘要: 1 var a = 1; 2 function aa(){ 3 a = 2; 4 } 5 aa(); 6 console.log("a:", a); // 2 7 8 var b = 1; 9 function bb(){10 b = 2;11 var b = 3;12 }13 bb();14 console.log("b:", b); // 115 16 function foo(){17 var a1 = 1;18... 阅读全文
posted @ 2013-09-27 10:35 楚玉 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 1 2 3 4 5 6 7 劲爆鸡米花 1 阅读全文
posted @ 2013-09-27 09:32 楚玉 阅读(232) 评论(0) 推荐(0) 编辑
摘要: 1 var i =0, count = 1; 2 3 // for 循环 跟 while循环 是一样的 可以互相转换 前测 4 /*while(i < 10){ 5 console.log("i is:", i); 6 i++; 7 }*/ 8 9 // A10 do{11 console.log("i::",i);12 13 console.log("count ---", count)14 count++;15 16 i+... 阅读全文
posted @ 2013-09-13 11:50 楚玉 阅读(247) 评论(0) 推荐(0) 编辑
摘要: 1 var btn = document.getElementById("btn"), show = document.getElementById("content"), count = 0; 2 btn.onmouseover = function(){ 3 console.log(this) 4 this.style.cssText = "cursor : pointer;"; 5 }; 6 btn.onclick = function(e){ 7 console.log(count); 8 if(... 阅读全文
posted @ 2013-09-12 16:26 楚玉 阅读(380) 评论(0) 推荐(0) 编辑
摘要: 1 ;(function(global){ 2 var wind = document.getElementById("wind"), count = 0; 3 4 function marque(){ 5 console.log("wind.offsetTop:",wind.offsetTop,"wind.offsetLeft::",wind.offsetLeft); 6 7 8 /*wind.style.left = 12 + wind.offsetLeft + "px"; 9 ... 阅读全文
posted @ 2013-09-12 16:24 楚玉 阅读(317) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 10 下一页