Search
 
SCRIPT & CODE EXAMPLE
 

HTML

how to unescape in html

Unescaping HTML in a string by replacing:
&lt; with <
&gt; with >
&quot; with "
&#39; with '
&amp; with &
  -----------------------------------
  function unEscape(htmlStr) {
    htmlStr = htmlStr.replace(/&lt;/g , "<");	 
    htmlStr = htmlStr.replace(/&gt;/g , ">");     
    htmlStr = htmlStr.replace(/&quot;/g , """);  
    htmlStr = htmlStr.replace(/&#39;/g , "'");   
    htmlStr = htmlStr.replace(/&amp;/g , "&");
    return htmlStr;
}

let unEscapedStr =unEscape(`&lt;script&gt;alert(&#39;hi&#39;)&lt;/script&gt;`);
console.log(unEscapedStr);
Comment

unescape html js

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
var Title = $('<textarea />').html("Chris' corner").text();
console.log(Title);
</script>
Comment

PREVIOUS NEXT
Code Example
Html :: embed instagram feed on website html 
Html :: encode plus sign in url 
Html :: html character encoding examples 
Html :: bootstrap move navlink to left side 
Html :: html projects 
Html :: html multi page website 
Html :: input telefono html 
Html :: HTML Start Example 
Html :: later synonym 
Html :: postcss minify 
Html :: html web page examples with source code 
Css :: placeholder font size 
Css :: disable highlight css 
Css :: css underline color 
Css :: button css shadow 
Css :: css contenteditable outline 
Css :: form field focus border remove css 
Css :: grid auto sizing 
Css :: add image ::before css 
Css :: 2 lines p css 
Css :: how to do a background blur in css 
Css :: css flip image horizontally 
Css :: input text field with only bottom border 
Css :: sass compressed style 
Css :: css input spaces between 
Css :: disable scroll css 
Css :: css last element with class name 
Css :: vertcial text css 
Css :: christmas red color code 
Css :: grid center align 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =