上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 24 下一页
摘要: 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"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html;ch 阅读全文
posted @ 2012-06-23 21:17 小猩猩君 阅读(186) 评论(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"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html;ch 阅读全文
posted @ 2012-06-23 20:02 小猩猩君 阅读(286) 评论(0) 推荐(0) 编辑
摘要: 1 //DOM原生 选择器API,IE8、FF3.5、safari3.1、chrome1、opera10支持 2 var errs = document.querySelectorAll('div.warning,div.notice'); 3 4 //使用getElementsByTagName() 5 var errs = [], 6 divs = document.getElementsByTagName('div'), 7 classname = ''; 8 for (var i = 0, len = divs.length; i < 阅读全文
posted @ 2012-06-23 10:40 小猩猩君 阅读(255) 评论(0) 推荐(0) 编辑
摘要: 1 function toArray(coll) { 2 for (var i = 0, a = [], len = coll.length; i < len; i++) { 3 a[i] = coll[i]; 4 } 5 return a; 6 } 7 8 //用法 9 var coll = document.getElementsByTagName('div');10 var arr = toArray(coll); 阅读全文
posted @ 2012-06-22 15:26 小猩猩君 阅读(156) 评论(0) 推荐(0) 编辑
摘要: innerHTML: 1 function tableInnerHTML() { 2 var i, h = ['<table border="1" width="100%">']; 3 h.push('<thead>'); 4 h.push('<tr><th>id<\/th><th>yes?<\/th><th>name<\/th><th>url<\/th><th>actio 阅读全文
posted @ 2012-06-20 15:12 小猩猩君 阅读(1437) 评论(0) 推荐(0) 编辑
摘要: 举例:location.href > window.location.href > window.location.href.toString()对象成员嵌套得越深,访问速度就会越慢。 阅读全文
posted @ 2012-06-20 13:23 小猩猩君 阅读(243) 评论(0) 推荐(0) 编辑
摘要: 1 function loadScript(url, callback) { 2 var script = document.createElement("script"); 3 script.type = "text/javascript"; 4 5 if (script.readyState) { //IE 6 script.onreadystatechange = function() { 7 if (script.readyState == "loaded" || script.readyState == "comp 阅读全文
posted @ 2012-06-19 16:17 小猩猩君 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 1 jQuery.preloadImages = function() {2 for(var i = 0; i < arguments.length; i++) {3 $("<img />").attr('src', arguments[i]);4 }5 };6 //用法7 $.preloadImages('image1.gif', '/path/to/image2.png', 'some/image3.jpg'); 阅读全文
posted @ 2012-06-19 12:50 小猩猩君 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 1 (function(){2 console.log(arguments instanceof Array); // false 3 var argsArray = Array.prototype.slice.call(arguments);4 console.log(argsArray instanceof Array); // true 5 }());getElementsByTagName返回的NodeList也可以转化成数组1 Array.prototype.slice.call(nodes) 阅读全文
posted @ 2012-06-19 11:10 小猩猩君 阅读(5764) 评论(1) 推荐(0) 编辑
摘要: 原始代码:1 var list = document.getElementById("myList");2 for (var i = 0; i < 10; i++) {3 var item = document.createElement("li");4 list.appendChild(item);5 item.appendChild(document.createTextNode("Item" + i));6 }使用文档碎片(fragment)后的代码1 var list = document.getElementById( 阅读全文
posted @ 2012-06-18 16:51 小猩猩君 阅读(305) 评论(0) 推荐(0) 编辑
上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 24 下一页