JQuery javascript replace special characters html entities

JQuery замена спец. символов в текста на HTML сущности - пример

На чистом JS так.

Следующий код заменит спец. символы на HTML сущности:

jQuery('<div />').text('Some text with <div>html</div>').html()

and the output will look like

"Some text with <div>html</div>"

Чтобы раскодировать (обратная операция):

jQuery('<div />').html('Some text with <div>html</div>')

Получим:

Subscribe to RSS - JQuery javascript replace special characters html entities