Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function e(type, opts) {
- var i;
- if (!opts) opts = {};
- i = type.indexOf(".");
- if (i >= 0) { opts.className = type.slice(i+1); type = type.slice(0, i); }
- i = type.indexOf("#");
- if (i >= 0) { opts.id = type.slice(i+1); type = type.slice(0, i); }
- var d = document.createElement(type||"div");
- if (opts.className) d.className = opts.className;
- if (opts.id) d.id = opts.id;
- if (opts.parent) opts.parent.appendChild(d);
- Object.keys(opts).forEach(function(k){
- if (k !== "parent" && k !== "className" && k !== "id") {
- if (k.slice(0, 2) == "s_") {
- d.style[k.slice(2)] = opts[k];
- } else {
- d[k] = opts[k];
- }
- }
- });
- Array.prototype.slice.call(arguments, 2).forEach(function(c) {
- if (typeof c === "string") {
- d.appendChild(document.createTextNode(c))
- } else {
- d.appendChild(c);
- }
- });
- return d;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement