-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.dom-helper.js
39 lines (37 loc) · 1022 Bytes
/
jquery.dom-helper.js
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
/* The arguments passed in the method will be considered as classes */
var DOM = {
article: function article() {
return DOM.create(arguments.callee.name, arguments);
},
p: function p() {
return DOM.create(arguments.callee.name, arguments);
},
img: function img() {
return DOM.create(arguments.callee.name, arguments);
},
span: function span() {
return DOM.create(arguments.callee.name, arguments);
},
section: function section() {
return DOM.create(arguments.callee.name, arguments);
},
strong: function strong() {
return DOM.create(arguments.callee.name, arguments);
},
div: function div() {
return DOM.create(arguments.callee.name, arguments);
},
a: function a() {
return DOM.create(arguments.callee.name, arguments);
}
};
DOM.addClasses = function(element, classes) {
for (var i = 0; i < classes.length; i++) {
$(element).addClass(classes[i]);
};
}
DOM.create = function(tag, classes) {
var element = $("<" + tag + "/>");
DOM.addClasses(element, classes);
return element;
};