Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js encode to &

function encodeToAmp(text) {
  var el = document.createElement("div");
  
  el.textContent = text;
  el.innerText = text;
  return el.innerHTML;
}

encodeToAmp('&;'><"')  //  =>  &amp;;'&gt;&lt;"
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #js #encode
ADD COMMENT
Topic
Name
7+7 =