javascript htmlentities

Solutions on MaxInterview for javascript htmlentities by the best coders in the world

showing results for - "javascript htmlentities"
Jaylon
08 May 2017
1var sanitizeHTML = function (str) {
2	var temp = document.createElement('div');
3	temp.textContent = str;
4	return temp.innerHTML;
5};
Nathan
04 May 2017
1function htmlEntities(str) {
2    return String(str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
3}