0

I have a textarea from I got the value like this $(ctrl).val() then I receive this %3ch1%3eMy System%3c/h1%3e so I've been trying to encode this value into this:

<h1>My System</h1>

But I don't know how.

I found on internet many examples like this

jQuery('<div />').html('Some text with &lt;div&gt;html&lt;/div&gt;').text()

But no success! The decode text is different.

1 Answer 1

4

It's inherently unsafe/insecure to randomly unescape HTML content unless you know where its coming from (fully).

In any case:

unescape('%3ch1%3eMy System%3c/h1%3e') = "<h1>My System</h1>"

Sign up to request clarification or add additional context in comments.

1 Comment

Note that unescape is officially deprecated, in this instance you can use replace that method call with decodeURIComponent() to the same (but actually, it's not exactly the same) effect.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.