Encode to HTML

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

 

Decode 

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

資料來源 https://coderwall.com/p/jt7ysq/encode-string-to-html-entities-via-jquery

相关文章