摘要: 1.文字时间: 2.图片时间: 3.倒计时: 阅读全文
posted @ 2016-07-23 21:34 河南小样 阅读(197) 评论(0) 推荐(0) 编辑
摘要: 1.清空整个: 2.清空前一个: 3.自动轮播: 4.用户体验好的选项卡: 阅读全文
posted @ 2016-07-23 20:54 河南小样 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 碰撞检测: function collTest(obj1,obj2){//由于if判断条件是对称的,obj1,obj2谁在前无所谓 //用于获取四条边的相对距离 var l1=obj1.offsetLeft; var r1=obj1.offsetLeft+obj1.offsetWidth; var 阅读全文
posted @ 2016-07-23 14:51 河南小样 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 简单拖拽: window.onload=function(){ var oBox=document.getElementById("box"); oBox.onmousedown=function(ev){ var e=ev||event; var disX=e.clientX-oBox.offse 阅读全文
posted @ 2016-07-23 14:49 河南小样 阅读(142) 评论(0) 推荐(0) 编辑
摘要: 克隆: obj.cloneNode();//是否深度克隆;true:深度克隆, 删除一个属性:obj.removeAttribute('属性名'); window.onload=function(){ var oBox=document.getElementById("box"); var oBtn 阅读全文
posted @ 2016-07-23 14:43 河南小样 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 右键菜单[上下文菜单]:oncontextmenu 浏览器自带的: a标签可以点击,输入框可以输入文字,可以选中文字···· 阻止浏览器默认:return false; window.onload=function(){ var oMenu=document.getElementById("menu 阅读全文
posted @ 2016-07-23 14:41 河南小样 阅读(515) 评论(0) 推荐(0) 编辑
摘要: 一串跟着鼠标的div: window.onload=function(){ var oBox=document.getElementById("box"); var aDiv=oBox.getElementsByTagName('div'); for(var i=0;i<20;i++){ //创建2 阅读全文
posted @ 2016-07-23 14:40 河南小样 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 事件对象: event:描述或者包含事件的更加详细的信息; event:不兼容FF; ev: 兼容IE9+,FF,Chrome,IE8--报undefined; 兼容写法:var oEvent=ev||event; clientX:X轴的坐标 clientY:Y轴的坐标 冒泡: 子元素的事件可以传递 阅读全文
posted @ 2016-07-23 14:36 河南小样 阅读(193) 评论(0) 推荐(0) 编辑
摘要: 关于form: 网址:https://www.baidu.com/?a=1&b=2 ?前面是纯网址,?后面是我们提交的数据;提交的多个数据用&隔开; 提交方式[method]:如果不写提交方式,默认是get; 1>.get: 不安全,容量(32KB),有缓存,适合做收藏和分享 2>.post: 相对 阅读全文
posted @ 2016-07-23 14:30 河南小样 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 瀑布流: 1.等宽不等高; 2.拉不到底; 每次往offsetHeight最小的Ul里面添加 function rand(n,m){ return parseInt(Math.random()*(m-n)+n) //随机数 } function createLi(){ var oLi=documen 阅读全文
posted @ 2016-07-23 14:26 河南小样 阅读(142) 评论(0) 推荐(0) 编辑
摘要: 进度条: window.onload=function(){ var oBox1=document.getElementById("box1"); var oBox2=document.getElementById("box2"); var num=0; for(var i=0;i<77;i++){ 阅读全文
posted @ 2016-07-23 14:17 河南小样 阅读(582) 评论(0) 推荐(0) 编辑
摘要: 地址栏信息: window.location: window.location.href="http://www.baidu.com"//打开一个页面 window.location.search :获取地址栏问号后面的东西; window.location.port:端口号; window.loc 阅读全文
posted @ 2016-07-23 14:12 河南小样 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 动态创建元素: document.createElement('元素名'); 删除元素: 父级.removeChild(要删除的元素); 添加元素: 父级.appendChild(要添加的元素) >往后面添加; 父级.insertBefore(要添加的元素,添加到谁的前面) >往某个元素前面添加; 阅读全文
posted @ 2016-07-23 11:05 河南小样 阅读(123) 评论(0) 推荐(0) 编辑
摘要: 上下一个兄弟节点,第一个和最后一个子节点[不兼容]: 兼容性问题解决方案: var oNext = obj.nextElementSibling || obj.nextSibling; obj.nextSibling: 所有的浏览器都支持这个方法,只不过高版本浏览器[IE9+]中会识别文本节点[普通 阅读全文
posted @ 2016-07-23 11:03 河南小样 阅读(816) 评论(0) 推荐(0) 编辑
摘要: 异常:try{}catch(e){}//异常捕获;救急用;也可以当做if来使用; window.onload=function(){ var oBox=document.getElementById("box"); oBox.onclick=function(){ try{alert(getComp 阅读全文
posted @ 2016-07-23 10:59 河南小样 阅读(207) 评论(0) 推荐(0) 编辑
摘要: 模拟数组排序: var arr=[2,45,78,12,46,1]; function findInMin(arr,start){ //从第start位往后找最小值 var iMin=arr[start];//假设第start个数为最小值; var iMinIndex=start;//假设最小值的下 阅读全文
posted @ 2016-07-23 10:41 河南小样 阅读(116) 评论(0) 推荐(0) 编辑
摘要: 封装getByClass function findInArr(n,arr){ for(var i = 0 ;i < arr.length; i++){ if(n == arr[i]){ return true; } } return false; } //oParent:父级 sClass:我们要 阅读全文
posted @ 2016-07-23 10:38 河南小样 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 数组去重: a. arr.sort(); //sort法 for(var i=0;i<arr.length;i++){ if(arr[i]==arr[i+1]){ arr.splice(i,1); i--; } } alert(arr); b. function findInArr(n,arr){ 阅读全文
posted @ 2016-07-23 10:38 河南小样 阅读(118) 评论(0) 推荐(0) 编辑
摘要: QQ长图: window.onload=function(){ var oBox=document.getElementById("box");//盒子 var aImg=oBox.getElementsByTagName('img')[0];//图片 var oUp=document.getEle 阅读全文
posted @ 2016-07-23 10:34 河南小样 阅读(191) 评论(0) 推荐(0) 编辑
摘要: 封装补零函数: function toDouble(n){ if(n < 10){ return '0' + n; }else{ return '' + n; } } 封装随机数函数: function rand(n,m){ return parseInt(Math.random()*(m-n)+n 阅读全文
posted @ 2016-07-23 10:33 河南小样 阅读(1557) 评论(0) 推荐(0) 编辑