自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(29)
  • 收藏
  • 关注

原创 获取页面、可视区域、容器本身高度宽度

1,获取页面的高度宽度var sHeight=document.documentElement.scrollHeight;var sWidth=document.documentElement.scrollWidth;2,获取可视区域的高度宽度var cHeight=document.documentElement.clientHeight;var cWidth=documen

2017-03-16 09:13:40 671

原创 children--- 只读属性---子节点列表集合

元素.children : 只读 属性 子节点列表集合        标准下:只包含元素类型的节点      非标准下:只包含元素类型的节点元素.children兼容好,常用!!!元素.childNodes : 只读 属性 子节点列表集合          标准下:包含文本和元素类型的节点,也会包含非法嵌套的子节点        非标准下:只包含元素类型的节

2017-03-12 21:25:53 622

原创 concat(),reverse(),字符串取反

concat():var arr1=[1,2,3,4];var arr2=['marie','tony'];var arr3=['safe','sound'];alert(arr1.concat(arr2,arr3))reverse():var arr1=[1,2,3,4,55,4,33,22];alert(arr1.reverse())字符串取反:先通过s

2017-03-12 18:49:21 2139

原创 ceil()向上取整与round()逢五进一

取1~5随机数的两种方法:Math.ceil(Math.random()*5)Math.round(Math.random()*(5-1)+1)alert(Math.round(Math.random()*(y-x)+x)); //x~yalert(Math.round(Math.random()*80+20))//20~100alert(Math.round(Math

2017-03-12 18:08:07 1357

原创 数组排序sort()用法

1.字符串排序var arr=['a','b','a','f','e'];arr.sort();alert(arr);  2.数字排序var arr=[3,1,9,4,87]arr.sort();arr.sort(function(x,y){return x-y;})alert(arr)3.带字符的数字大小排序var arr=['34px','345

2017-03-12 17:06:18 865

原创 1种数组去重的方法

var arr=[1,2,3,1,4,5,1];for(var i=0;ifor(var j=i+1;jif(arr[i]==arr[j]){arr.splice(j,1);j--;}}}alert(arr)

2017-03-12 16:29:51 176

原创 数组中的splice()

splice(index,num,string)删除:var arr=['smile',2,3,'marie'];arr.splice(0,2)   //从第一个值(0)开始删除该数据的两(2)个值alert(arr.splice(0,2)) //返回 smile,2alert(arr)  //返回3,marie修改:var arr=['smile',2,3,'

2017-03-12 16:22:44 1441

原创 数组的4个方法

应用arr.push(arr.shift())alert(arr) //返回 2,3,marie,smilearr.unshift(arr.pop())alert(arr) //返回 marie,smile,2,3

2017-03-12 13:01:51 232

原创 数组的length属性可读可写,字符串的长度length属性不可以修改

数组的length属性可读可写,字符串的长度length属性不可以修改清空数组的两种方法:arr.length=0;arr=[];

2017-03-12 11:53:09 3646

原创 遍历对象

var str='';var num=1;for(var attr in document){                     //window or document objectstr+=num+'. '+attr+':'+document[attr]+'';num++;}document.body.innerHTML=str;

2017-03-12 10:49:57 171

原创 str.charCodeAt()与String.fromCharCode()用法

str='123';str.charCodeAt(0)=48;str的值为0~9str.charCodeAt(i)的值为48~57str的值为a~zstr.charCodeAt(i)的值为97~122str的值为A~Zstr.charCodeAt(i)的值为65~90String.fromCharCode(48, 49)=01st

2017-03-08 15:13:00 2036

原创 封装好的运动方法

function move(obj,val,target,dir,endFn){val=parseInt(getStyle(obj,dir))clearInterval(obj.timer);obj.timer=setInterval(function(){var speed=parseInt(getStyle(obj,dir))+val;if(speed>=target&&v

2017-03-05 15:03:48 284

原创 获取样式方法

function getStyle(obj,sty){return obj.currentStyle?obj.currentStyle[sty]:getComputedStyle(obj)[sty];}

2017-03-04 21:16:35 169

原创 函数调用参数判断

function fn1(a){if(typeof a==='number' && a===a) //a是数字且不是NaN{alert(a+8);}else if(typeof a==='string'){alert(a.charAt(3));}else if(typeof a==='function'){a();}}fn1(100);fn1('mari

2017-02-28 16:22:47 546

原创 parseFloat(c)==parseInt(c)小应用

var c='209.87';if(parseFloat(c)==parseInt(c)){alert(c+'是整数!');}else{alert(c+'是浮点数!');}

2017-02-27 23:05:06 260

原创 修改ul下li下的ul下的li的css样式

修改ul下的ul下的li的css样式window.onload=function(){var oUl=document.getElementById('list');var arrUl=oUl.getElementsByTagName('ul');var ulLen=arrUl.length;var arrLi=null;for(var i=0;iarrLi=arr

2017-02-24 22:38:37 3778

原创 二维数组中的for循环

二维数组中的for循环window.onload=function(){var arr=[['tony','jenny','marie','nal'],[1,2,3,4,5],['aa','bb','cc','dd']];var len=arr.length;for(var i=0;ivar  sLen=arr[i].length;for(var j=0;jaler

2017-02-24 21:14:32 859

原创 js中[]与.用法

js中[]与.用法*{margin: 0;padding: 0;}html,body{width: 100%;height: 100%;overflow: hidden;}.wrap{width: 100%;height: 100%;padding: 100px;background: darkgrey;color: white;

2017-02-22 23:11:24 440

原创 三列布局中间自适应的3种写法

定位法:*{margin: 0;padding: 0;}html,body{height: 100%;margin: 0;}.ll,.rr{position: absolute;top: 0;width: 200px;height: 100%;background: hotpink;}.ll{left: 0

2017-02-21 22:58:26 288

原创 each中的this

each中的this$(function(){$('li').each(function(i,elem){/*console.log(i);console.log(elem);*/console.log(this);     //this=elem$(this).html(i);if(i==4){return false;}})})

2017-02-17 14:16:25 512

原创 插件中的this

插件中的this#div1{width: 100px;height: 100px;background: red;position: absolute;}$(function(){$.extend({aaa:function(){alert(1111);}});$.fn.extend({drag:function(){va

2017-02-17 13:52:20 266

原创 remove()与detach()区别

remove()与detach()区别$(function(){$('div').click(function(){alert('tony');})// var oDiv=$('div').remove();var oDiv=$('div').detach();// remove()与detach()都是移除节点,detach()移除后再追加还有原节点的事件,r

2017-02-14 22:34:39 343

原创 display为none时jquery的outerWidth()与原生offsetWidth差别

display为none时jquery的outerWidth()与原生offsetWidth差别#div1{width: 100px;height: 100px;/*display: none;*/}$(function(){// alert($('#div1').outerWidth());alert($('#div1').get(0).offse

2017-02-14 21:50:58 874

原创 jquery拖拽方块效果

div{width: 100px;height: 100px;background: #fc0;position: absolute;}$(function(){var x=0;var y=0;$('div').mousedown(function(ev){x=ev.pageX-$(this).offset().left;y=ev.pageY

2017-02-13 22:59:31 613

原创 jquery创建水平居中垂直居中弹出框

*{margin: 0;padding: 0;}#login{width: 300px;height: 300px;border: 1px solid red;position: absolute;}#close{position: absolute;right: 5px;top: 5px;}$(function(){$(

2017-02-13 16:09:21 478

原创 jQuery中width(),innerWidth(),outerWidth(),outerWidth(true)

div{background: #fc0;width: 100px;height: 100px;padding: 10px;border: 10px solid red;margin: 10px;}$(function(){alert($('div').width());              //widthalert($('div').in

2017-02-12 22:38:39 366

原创 html5 canvas

canvas 默认宽高为300*150

2017-02-11 14:21:24 284

原创 35个数中随机抽取7个整数

window.onload=function(){var oBtn=document.getElementById('btn');var oDiv=document.getElementById('div1');oBtn.onclick=function(){oDiv.innerHTML=rNum(35,7);}function rNum(iAll,iNow){var

2017-02-10 22:00:59 1044

原创 近期前端笔记

1、tabindex="-1"则在使用[Tab]键时,此元素被忽略。注意:如果使用-1值时,onfocus与onblur事件仍被启动。2、button标签是行内元素3、40% Complete'sr-only'表示该元素不显示,只用于屏幕阅读器屏幕阅读器可以把"40% Complete"念出来,以方便残障人士4、三角形CSS:.abc{position: abs

2017-02-07 10:26:06 146

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除