Skip to content

Instantly share code, notes, and snippets.

@Shridhad
Created November 15, 2014 17:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shridhad/822e629e952c9af8c8af to your computer and use it in GitHub Desktop.
Save Shridhad/822e629e952c9af8c8af to your computer and use it in GitHub Desktop.
Convert the string into DOM element
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