How to Decode HTML Entities Using jQuery?

Learn how to decode HTML entities in jQuery using smart and efficient methods. Includes working examples and cross-browser techniques.

Decoding of HTML entities encoded string will be required specially during the AJAX operation. During AJAX operation, if we get HTML entities encoded string, it is required to be decoded before displayed to users. If you want to display HTML entities encoded string in textarea, then you can use following code,

var decode = $('<textarea/>').html(encoded).val();

If you want to display HTML entities encoded string in div, then you can use following code,

var decode = $('<div/>').html(encoded).text();

Comments

comments