convert html to javascript string code example
Example 1: Javascript convert html entity to string
const htmlEntities = {
"&": "&",
"<": "<",
">": ">",
'"': """,
"'": "'"
};
return str.replace(/([&<>\"'])/g, match => htmlEntities[match]);
}
Example 2: convert element to html string
html_entity_decode
$temp = "<font class='red font-price'> 30 </font>";
echo html_entity_decode($temp);