Possible Duplicate:
HTML Entity Decode
I want to convert this string
<p>update this post</p>
to
<p>update this post</p>
in Javascript.
Do you have any idea? Thanks in advance.
Possible Duplicate:
HTML Entity Decode
I want to convert this string
<p>update this post</p>
to
<p>update this post</p>
in Javascript.
Do you have any idea? Thanks in advance.
I'd create an element, set its innerHTML
and get its innerText
:
var element = document.createElement('div');
element.innerHTML = '<p>update this post</p> ';
console.log(element.innerText);
The result is:
"<p>update this post</p> "
Working example:
var text='<p>update this post</p>';
var d = document.createElement("div");
d.innerHTML=text;
alert(d.innerText || d.text || d.textContent);
You can use this method:
var param = '<p>update this post</p>';
unescape(param);