Created
November 15, 2014 17:38
-
-
Save Shridhad/822e629e952c9af8c8af to your computer and use it in GitHub Desktop.
Convert the string into DOM element
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
String.prototype.toDOM = function() { | |
var element = document.createElement("div"), | |
fragment = document.createDocumentFragment(); | |
element.innerHTML=this; | |
fragment.appendChild(element.firstChild); | |
return fragment; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment