I have code in javascript:
var location = '"HCM - NYC (New York, NY)"';
td_Details.innerText = location;
Now I want to decode the text location to
“HCM – NYC (New York, NY)”
Please advice. Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is no specific function in JavaScript which will decode HTML entities, however you can assign an
innerHTMLproperty to an element and then read it back.This will work for any HTML entities, not just "
edit:
As pointed out below, you’re half-way there, you’re just using the wrong property.
Change:
to:
For future reference,
innerHTMLis available in all browsers.innerTextis not.