Horje
js Convert the characters to the html Code Example
js Convert the characters to the html
//To do this simply create a element in the DOM tree and 
//set the innerText of the element to your string. 
//Then retrieve the innerHTML of the element. 
//The browser will return an HTML encoded string.

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

console.log(HtmlEncode('&;\'><"'));

//expected output: &amp;;'&gt;&lt;"




Javascript

Related
express get url parameters Code Example express get url parameters Code Example
discord.js bot Code Example discord.js bot Code Example
js timestamp Code Example js timestamp Code Example
timestamp js Code Example timestamp js Code Example
get random element from array js Code Example get random element from array js Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8