Skip to content

Instantly share code, notes, and snippets.

@darbicus
Created June 23, 2014 20:35
Show Gist options
  • Save darbicus/6831d52c6019afebca76 to your computer and use it in GitHub Desktop.
Save darbicus/6831d52c6019afebca76 to your computer and use it in GitHub Desktop.
Simple way to convert HTML to JS
var htmlToElements = (function () {
var div = document.createElement('div');
return function (s) {
div.innerHTML = s;
return div.childNodes;
};
}());
console.dir(htmlToElements('<div><span>test</span></div>'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment