Answers for "convert a string to html element in js"

4

convert a string to html element in js

/**
 * 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
0

convert a string to html element in js

<div style="border:1px solid black; margin-top:20px; height:500px; overflow:scroll;" id="messageBox" >
                        <div class="row " style="border: 1px solid black; margin:10px; ">
                            <p style="float: left;">User Name : </p> <p style="margin-left:2px; float: left;"> Message content</p>
                        </div>
                    </div>
Posted by: Guest on June-06-2021

Code answers related to "convert a string to html element in js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language