Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js convert special characters to html entities

// Add this function to your code
function HtmlEncode(s)
{
  var el = document.createElement("div");
  el.innerText = el.textContent = s;
  s = el.innerHTML;
  return s;
}

// Execute the function like this
HtmlEncode("Good Mornin'!")
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #js #convert #special #characters #html #entities
ADD COMMENT
Topic
Name
3+9 =