Created
April 7, 2009 20:08
-
-
Save appden/91433 to your computer and use it in GitHub Desktop.
This file contains 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 $E(tag, props) { | |
if (typeof props == 'string') | |
props = { style : props }; | |
if (typeof tag == 'string') { | |
var id = tag.match(/#([\w-]+)/); | |
var classes = tag.match(/(?:\.[\w-]+)+/); | |
tag = tag.replace(/[#.].*/, ''); | |
props = props || {}; | |
if (id) props.id = id[1]; | |
if (classes) props['class'] = classes[0].replace(/\./g, ' '); | |
} | |
return new Element(tag || 'div', props); | |
}; | |
/* | |
Please see for more info: | |
http://appden.com/javascript/element-creation-shortcut-in-mootools/ | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment