Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js create element from string

function createElementFromHTML(htmlString) {
  var div = document.createElement('div');
  div.innerHTML = htmlString.trim();

  // Change this to div.childNodes to support multiple top-level nodes.
  return div.firstChild;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #js #create #element #string
ADD COMMENT
Topic
Name
4+8 =