forked from dunizb/CodeTest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path创建DIV.html
58 lines (56 loc) · 1.21 KB
/
创建DIV.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>创建DIV</title>
</head>
<body>
<script type="text/javascript">
function DivTag(){
this.DOM = document.createElement("div");
this.appendTo = function( node ){
node.appendChild(this.DOM);
return this;
};
this.css = function(options) {
for(var k in options){
this.DOM.style[k] = options[k];
}
return this;
}
}
// function DivTag(){
// this.DOM = document.createElement("div");
// this.appendTo = function(node){
// node.appendChild(this.DOM);
// return this;
// },
// this.css = function(options){
// for(var k in options){
// this.DOM.style[k] = options[k];
// }
// return this;
// }
// }
//
// function DivTag(){
// this.DOM = document.createElement("div");
// this.appendTo = function(node){
// node.appendChild(this.DOM);
// return this;
// },
// this.css = function(options){
// for(var k in options){
// this.DOM.style[k] = options[k];
// }
// return this;
// }
// }
new DivTag().appendTo(document.body).css({
width:'200px',
height:'200px',
border:'1px solid red'
});
</script>
</body>
</html>