window.dom
window.dom = {
getId: function(id) {
return document.getElementById(id);
},
create: function(tag, attr) {
var el = document.createElement(tag);
for (var key in attr) {
el.setAttribute(key, attr[key]);
}
return el;
}
};
Usage:
var node = dom.create('div', {id: 'J_wrapper'});
input = dom.create('input', {
type: 'text',
value: 'xxxx',
name: 'username'
});
document.body.append(node);
// document.body.insertBefore(input, node);
node.append(input);