Search
 
SCRIPT & CODE EXAMPLE
 

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'!")
Comment

PREVIOUS NEXT
Code Example
Javascript :: declare empty object javascript 
Javascript :: datatable giving default width to colums 
Javascript :: electron open new window 
Javascript :: how to convert string into blob in javascript 
Javascript :: react native text input select all text on focus 
Javascript :: nextjs change port 
Javascript :: run a code after delay js 
Javascript :: Calling MVC controller from Javascript ajax 
Javascript :: expo go something went wrong network response timed out 
Javascript :: convert json result to datatable c# 
Javascript :: how to split two digit number in javascript 
Javascript :: print placeholder value js 
Javascript :: javascript function argument type 
Javascript :: javascrpt formatBytes 
Javascript :: how to hide javascript code 
Javascript :: js random in range 
Javascript :: how to make a vowel counter in javascript 
Javascript :: vue 3 computed getter setter 
Javascript :: how to add background image in mui 
Javascript :: redux dev tools 
Javascript :: remove from object javascript 
Javascript :: select all elements javascript 
Javascript :: how to kill all node processes in windows 
Javascript :: alphabet as array javascript 
Javascript :: django jquery 
Javascript :: how to display api data in html 
Javascript :: jquery checkbox unchecked 
Javascript :: javascript sql 
Javascript :: loop through array backwards 
Javascript :: function js format money 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =