Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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;"
Comment

javascript covert html characters to text

const decodeHTML = s => {
    var str, temp= document.createElement('p');
    temp.innerHTML= s;
    str= temp.textContent || temp.innerText;
    temp=null;
    return str;
}

console.log(decodeHTML('&lt;'));
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript get token from query string 
Javascript :: Baris (Record/Tuple adalah] 
Javascript :: underscore js shuffle 
Javascript :: react Bootstrap Five Heart rating 
Javascript :: adding items to extjs container 
Javascript :: provider not found react 
Javascript :: change the input feild name when the div contaoining that field is cloned using jquery 
Javascript :: nestjs mongoose ClassSerializerInterceptor not working 
Javascript :: { "rules": { ".read": true, ".write": true } } 
Javascript :: how remove prperty or object in javscript 
Javascript :: discord javascript error on startup 
Javascript :: jquery validate required false with additional function 
Javascript :: sum the two first minimum numbers in an array 
Javascript :: animate on scroll angular 
Javascript :: updater function 
Javascript :: catch the last item in a array js 
Javascript :: how to regexp replace with uppercase on specific capture group in js 
Javascript :: how to make a <li when clicked on a button js 
Javascript :: knex update and list all record mysql 
Javascript :: get values from string with delimiter google script 
Javascript :: object mapper pretty write as string 
Javascript :: javascript reduce array of objects group by property 
Javascript :: How to show content-type:image/jpg in react 
Javascript :: installing toast for angular projects 
Javascript :: Timestamp Format: 23.12.2015 08:34:50 
Javascript :: js remove undefined object 
Javascript :: petru a retuna toate toate datele in java script 
Javascript :: javascript capitalize every word in a string 
Javascript :: limit frontend request 
Javascript :: SHOPIFY CUSTOMER WITH REGISTRATION 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =