摘要:
1 //定义 walk_the_DOM 函数,它从某个给定的节点开始,按HTML源码中的顺序访问该树的每个节点 2 //它会调用一个函数,并依次传递每个节点给它。walk_the_DOM 调用自身去处理每一个子节点。 3 var walk_the_DOM = function walk(node, func) { 4 func(node); 5 node = node.firstChild; 6 while (node) { 7 walk(node, func); 8 node = node.ne... 阅读全文
posted @ 2012-07-09 22:17
小猩猩君
阅读(449)
评论(0)
推荐(0)
摘要:
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> 3 <head> 4 <meta http-equiv="Content-Type" co 阅读全文
posted @ 2012-07-09 15:11
小猩猩君
阅读(269)
评论(2)
推荐(0)
摘要:
1 var hanoi = function(disc, src, aux, dst) {2 if (disc > 0) {3 hanoi(disc - 1, src, dst, aux);4 document.writeln('Move disc ' + disc + ' from ' + src + ' to ' + dst + '<br/>');5 hanoi(disc - 1, aux, src, dst);6 }7 };8 hanoi(3, 'Src', 'Aux', & 阅读全文
posted @ 2012-07-09 14:06
小猩猩君
阅读(165)
评论(0)
推荐(0)
摘要:
1 Function.prototype.method = function(name, func) { 2 if (!this.prototype[name]) { 3 this.prototype[name] = func; 4 } 5 }; 6 7 //根据数字的正负来判断使用哪个方法 8 Number.method('integer', function() { 9 return Math[this < 0 ? 'ceil' : 'floor'](this);10 });11 document.writeln((-10 / 3).i 阅读全文
posted @ 2012-07-09 13:07
小猩猩君
阅读(170)
评论(0)
推荐(0)

浙公网安备 33010602011771号