随笔分类 -  JavaScript

原生javascript
摘要:<script> // 一句话 在构造函数里面写属性 在原型里面写方法 function Elem(d){ this.even=document.getElementById(d); } Elem.prototype.html=function(val){ var e = this.even; if 阅读全文
posted @ 2017-08-30 14:56 xuanPhoto 阅读(471) 评论(0) 推荐(0) 编辑
摘要:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>Document</title> </head> <body> </body> <script type="text/javascript" > // 通过 阅读全文
posted @ 2017-08-26 12:57 xuanPhoto 阅读(221) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2017-08-23 15:08 xuanPhoto 阅读(135) 评论(0) 推荐(0) 编辑
摘要:var obj = new Object(); obj.name='Zachary'; obj.showname=function(){ alert(this.name) } obj.showname() // 任何对象都可以new function test(){... 阅读全文
posted @ 2017-08-22 22:33 xuanPhoto 阅读(124) 评论(0) 推荐(0) 编辑
摘要:var arr = new Array(12,13,14,15,16,17,18); var arr2 = new Array(12,13); arr.sun=function(){ //用原型加Array.prototype.sun=function() 下面的alert(arr2.sun())生 阅读全文
posted @ 2017-08-22 22:32 xuanPhoto 阅读(368) 评论(0) 推荐(0) 编辑
摘要:什么是对象 对象是一个整体,对外提供一些操作 就像黑盒子,不了解内部结构,但知道表面的各种操作 比如遥控器这个对象 什么是面向对象 在不了解原理的情况下会使用功能 使用对象时,只关注对象提供的功能,不关注内部实现和细节,比如jquery 面向对象是一种通用思想,并非编程中能用,任何事情都可以 为何使 阅读全文
posted @ 2017-08-22 22:20 xuanPhoto 阅读(894) 评论(0) 推荐(0) 编辑
摘要:<button id='btn'>attachEvent</button> window.onload=function(){ var Obtn = document.getElementById('btn'); Obtn.onclick=function(){ alert(1) } // 只兼容I 阅读全文
posted @ 2017-08-04 09:57 xuanPhoto 阅读(2032) 评论(0) 推荐(0) 编辑
摘要:require是commonjs规范,是node的写法,webpack帮你做了语法转换,不单单是webpack可以做这事,gulp-browsers,requirejs一样可以 Node是commonjs规范,用require导入js模块,通过webpack等构建工具把require的js包注入到页面上,import是ES6/7的语法,如果浏览器支持,理论上不用构建工具就可以当作模块导入 n... 阅读全文
posted @ 2017-07-31 15:48 xuanPhoto 阅读(277) 评论(0) 推荐(0) 编辑
摘要:用Es6对象扩展运算符(…)与rest运算符说明 function test (...a) { for (let val = 0; val < a.length; val++) { console.log(val + ' ' + '常用的 for循环') // 0-7 便利出下标 } for (le 阅读全文
posted @ 2017-06-28 11:33 xuanPhoto 阅读(311) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2017-06-22 15:16 xuanPhoto 阅读(177) 评论(0) 推荐(0) 编辑
摘要:html打印结果子元素以及自身 <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> </head> <style type="text/css"> .demo{width: 300px;height: 200px;border 阅读全文
posted @ 2017-06-21 14:10 xuanPhoto 阅读(155) 评论(0) 推荐(0) 编辑
摘要:css html javascript 阅读全文
posted @ 2017-06-20 13:24 xuanPhoto 阅读(259) 评论(0) 推荐(0) 编辑
摘要:随机取数方法 Math.random() 表示0到1之间随机取一个数 0<x<1 小数 Math.random()*5 表示0<x<5 parseInt(Math.random()*5) 0 1 2 3 4 中随机取一个数 公式:表示0到n 的随机取数(整数) parseInt(Math.random()*(n+1)) 阅读全文
posted @ 2017-06-19 12:05 xuanPhoto 阅读(212) 评论(0) 推荐(0) 编辑
摘要:test function demo(){ return function test(a){ alert($(a).text()) } } demo() 阅读全文
posted @ 2017-06-15 11:36 xuanPhoto 阅读(175) 评论(0) 推荐(0) 编辑
摘要:点击 点击 点击 阅读全文
posted @ 2017-05-08 10:56 xuanPhoto 阅读(579) 评论(0) 推荐(1) 编辑
摘要:1 2 3 阅读全文
posted @ 2017-05-06 16:40 xuanPhoto 阅读(128) 评论(0) 推荐(0) 编辑
摘要://原生js window.onresize = function() { console.log(document.body.clientWidth); } // jq方式 $(window).resize(function(){ console.log($(document.body).widt 阅读全文
posted @ 2017-04-09 11:40 xuanPhoto 编辑
摘要:console.time('计时器'); for (var i = 0; i < 1000; i++) { for (var j = 0; j < 1000; j++) {} } console.timeEnd('计时器'); 阅读全文
posted @ 2017-02-18 11:24 xuanPhoto 阅读(163) 评论(0) 推荐(0) 编辑
摘要:var inp1=document.getElementById('inp1'); inp1.onfocus=function(){ if(inp1.value=="请输入..."){ inp1.value=""; inp1.style.color="white"; } } inp1.onblur=fu... 阅读全文
posted @ 2017-01-18 18:29 xuanPhoto 编辑

点击右上角即可分享
微信分享提示