This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
th,td{padding:0;} | |
table{border-collapse:collapse;} | |
/* table css reset */ | |
th,td{border:1px solid black; height:50px; width:100px;} | |
table{width:500px;} | |
注意事项: | |
1、不要给table,th,td以外的表格标签加样式; | |
2、单元格默认平分table 的宽度 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//深拷贝 | |
function deepCopy(obj){ | |
if(typeof obj != 'object') { | |
return obj; | |
} | |
var newObj = {}; | |
for(var attr in obj) { | |
newObj[attr] = deepCopy(obj[attr]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1、所有书写均在英文半角状态下的小写; | |
2、id,class必须以字母开头; | |
3、所有标签必须闭合; | |
4、html标签用tab键缩进; | |
5、属性值必须带引号; | |
6、<!-- html注释 --> | |
7、/* css注释 */ | |
8、ul,li/ol,li/dl,dt,dd拥有父子级关系的标签; | |
9、p,dt,h标签 里面不能嵌套块属性标签; | |
10、a标签不能嵌套a; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
匹配中文:[\u4e00-\u9fa5] | |
行首行尾空格:^\s*|\s*$ | |
Email:^\w+@[a-z0-9]+(\.[a-z]+){1,3}$ | |
网址:[a-zA-z]+://[^\s]* | |
QQ号:[1-9][0-9]{4,9} | |
邮政编码:[1-9]\d{5} | |
身份证:[1-9]\d{14}|[1-9]\d{17}|[1-9]\d{16}x | |
匹配中文标点:[,。?:;‘’!“”—……、【】《》()] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
当我们在使用new操作符,函数(构造函数)中到底放生了什么? | |
1.创建一个空对象 | |
2.让空对象的__proto__(这个不同浏览器不同)成员指向了构造函数对象prototype成员对象 | |
3.将构造函数对象的this指针替换成空对象,然后再调用Base函数 | |
4.返回this对象 | |
例如 | |
function Foo(name){ | |
this.name = name; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Foo(){ | |
this.bar = "bar";//普通属性 | |
} | |
Foo.prototype.bar = "prototype bar"; //原型属性 | |
var f = new Foo(); | |
f.bar //"bar" | |
使用类比记忆 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//JavaScript继承 | |
//copy继承(call and prototype) | |
function extend(obj1, obj2){ | |
for(var attr in obj2){ | |
obj1[attr] = obj2[attr]; | |
} | |
} | |
function Person(name){ | |
this.name = name; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//JavaScript 类式继承 | |
//YUI2.9 YHAOO.lang.extend | |
function extend(Sub, Super) { | |
var F = function(){}; | |
F.prototype = Super.prototype; | |
Sub.prototype = new F(); | |
Sub.prototype.constructor = Sub; | |
} | |
function Person(name){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//JavaScript 原型继承 | |
function extend(obj){ | |
var F = function(){}; | |
F.prototype = obj; | |
return new F(); | |
} | |
var obj = { | |
name: "xxxx" | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! normalize.css v3.0.1 | MIT License | git.io/normalize */ | |
/** | |
* 1. Set default font family to sans-serif. | |
* 2. Prevent iOS text size adjust after orientation change, without disabling | |
* user zoom. | |
* 1. 设置默认的字体sans-serif. | |
* 2. 当屏幕方向改变的时候, 阻止ios自动调整文本大小. | |
* https://developer.mozilla.org/en-US/docs/Web/CSS/text-size-adjust | |
*/ |
OlderNewer