Answers for "convert string to html data"

17

html string to html

/**
 * Convert a template string into HTML DOM nodes
 * @param  {String} str The template string
 * @return {Node}       The template HTML
 */
var stringToHTML = function (str) {
	var parser = new DOMParser();
	var doc = parser.parseFromString(str, 'text/html');
	return doc.body;
};
Posted by: Guest on May-28-2020
1

string to html

const stringToHTML =  string=> new DOMParser().parseFromString(string, 'text/html').body.firstChild
Posted by: Guest on February-05-2022

Code answers related to "convert string to html data"

Code answers related to "Javascript"

Browse Popular Code Answers by Language