- 博客(18)
- 收藏
- 关注
原创 es6取两个数组重叠与不重叠
var numbers1 = [45, 4, 9, 16, 25];var numbers2 = [45, 4];//重叠let overlap = numbers1.filter((v,i)=>{ return numbers2.some((v2, i2)=>{ return v == v2 });})console.log(overlap);//(2) [45, 4]//不重叠let noO...
2020-09-28 17:16:44 752
原创 vue浏览器与body宽高获取
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>vue浏览器与body...
2020-05-18 14:45:31 6096
原创 FileReader和FormData一起实现头像图片变更
html<label style="height: 100px;position:relative;width: 80px"> <input type="file" name="file" accept="image/*" id="file" style="position: absolute;height: 100px;width: 80px"...
2020-05-06 16:41:36 227
原创 每日一个js实例15--canvas绘图内容打印
打印 不被打印区域 function fun(id){return document.getElementById(id);} var canvas=fun("canvas1"); var c=canvas.getContext("2d"); c.fillRect(100,100,200,200); //IE不支持d
2016-12-09 09:23:01 4376
原创 每日一个js实例14--随机数
var alldata="A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z";//在两个整数中间取随机数,有最小无最大var data=alldata.split(",");var len=data.length;alert(len);var timer=null;function num(min,max){ va
2016-11-16 09:15:45 327
原创 每日一个js实例13--通过曲线反应json数据
浏览器暂不支持h5的canvas元素 var arrLine=[]; $.ajax({ url : "../data/test.json", dataType:"json", async:false,//因为ajax是异步执行,所以当数据获取过程中,已经开始执行下面代码,这样下面的曲线数据无法获取,通过此设定为同步就可以
2016-11-14 08:51:18 323
原创 每日一个js实例12--广告切换效果
div{height: 200px; width:200px;border: 1px solid blue;overflow: hidden;margin: 10px auto} img{height: 200px; width:200px;} window.onload= function () { var oDi
2016-11-11 15:55:40 596
原创 每日一个js实例11--上下左右键
#box{width: 100px;height: 100px;position: absolute;background:pink;} function $(id){return document.getElementById(id)}; document.onkeydown=function(e){
2016-11-08 09:52:48 205
原创 每日一个js实例10--回车键
function $(id){return document.getElementById(id)} //鼠标事件 btn.onclick=function(){ if($("put").value == ""){ alert("请输入发表内容");
2016-11-07 08:57:43 193
原创 每日一个js实例9--NaN
+ //NaN not a number任何数字或字符串与NaN相加都是NaN,isNaN用于检测是否为NaN,返回值为布尔值 //普通函数 function $(id){return document.getElementById(id)} var num1=$("num1"); var n
2016-11-04 09:28:58 319
原创 每日一个js实例8--通过面向对象实现拖拽
#div1,#div2{background: red;width: 300px;height: 300px;position: absolute;} //第一种写法将属性包装入构造函数中 // function Drag(id){ // this.oDiv=document.getElementById(id);
2016-11-03 08:49:36 1146
原创 每日一个js实例7--通过面向对象实现选项卡
1 2 3 #box input{background: gray;} #box div{width: 200px;height: 200px;border: 1px solid red;display: none} #box .active{background: g
2016-11-02 10:04:03 338
原创 每日一个js实例6--通过面向对象实现进度条
#canvas1{width: 500px;height: 500px;background:gray;} //requestAnimFrame兼容性处理 window.requestAnimFrame = (function(){ return window.requestAnimationFrame || window.w
2016-11-01 09:52:02 400
原创 每日一个js实例5--通过面向对象实现运动
#div1{width: 200px;height: 200px;background: pink;position: absolute;}//requestAnimFrame兼容性处理 window.requestAnimFrame = (function(){ return window.requestAnimationFrame ||
2016-10-31 08:42:17 277
原创 每日一个js实例4---DOM操作ul排序
28 3 13 //1.依次替换 function $(id){return document.getElementById(id)}; var aLi=$("ul1").getElementsByTagName("li"); var oUL2=document.createElement("u
2016-10-28 09:32:35 966
原创 每日一个js实例3-不同格式json解析
index1.json:{ "A":[ {"name":"zhangsan"}, {"sex":"man"}, {"age":23} ], "B":[3,4,1,23,54] } $.ajax({ url:"../data/index1.json", type:
2016-10-27 09:10:21 276
原创 每日一个js实例2--js与jq实现走马灯
1,title内容申明每日一个js实例2,jq引入3,自己编写js代码 //js实现走马灯 function next(){ var oTitle=document.title; alert(oTitle); var fir=oTitle.charAt(0)
2016-10-26 08:45:51 690
原创 每日一个js实例1---纯js与canvas实现心电图网格绘制
canvas id="ecg1">浏览器暂不支持h5的canvas元素canvas>function drawGrid(id){ this.c_canvas = document.getElementById(id); this.context =this. c_canvas.getContext("2d"); this.w = this.c_can
2016-10-25 16:19:08 2633
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人