Created
April 5, 2011 02:25
-
-
Save odiak/902916 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
jQuery.create = function (tagName, innerText, attributes) { | |
var res; | |
if (typeof innerText === "undefined" || !innerText) { | |
innerText = ""; | |
} | |
if (typeof attributes === "undefined" || !attributes) { | |
attributes = {}; | |
} | |
if (tagName) { | |
var e = document.createElement(tagName); | |
if (innerText) { | |
e.innerHTML = innerText; | |
} | |
var attr; | |
for (attr in attributes) { | |
if (attributes.hasOwnProperty(attr)) { | |
e[attr] = attributes[attr]; | |
} | |
} | |
res = $(e); | |
} else { | |
res = false; | |
} | |
return res; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment