Unescaping HTML in a string by replacing:
< with <
> with >
" with "
' with '
& with &
-----------------------------------
function unEscape(htmlStr) {
htmlStr = htmlStr.replace(/</g , "<");
htmlStr = htmlStr.replace(/>/g , ">");
htmlStr = htmlStr.replace(/"/g , """);
htmlStr = htmlStr.replace(/'/g , "'");
htmlStr = htmlStr.replace(/&/g , "&");
return htmlStr;
}
let unEscapedStr =unEscape(`<script>alert('hi')</script>`);
console.log(unEscapedStr);
<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>
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 |