Created
June 22, 2009 16:30
-
-
Save oskarkrawczyk/134059 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Scott Kyle (http://appden.com) | |
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); | |
}; | |
// $E('div#theId.theClass').inject(document.body); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment