jQuery Encode string to HTML entities

#decode#encode#html entities#jquery
// Encode to HTML entities
$('<div />').text('Your text with <div>HTML Contennt</div>').html();

// Returns
"Your text with &lt;div&gt;HTML Contennt&lt;/div&gt;"
// Decode from HTML entities
$('<div />').html('Your text with &lt;div&gt;HTML Content&lt;/div&gt;').text();

// Returns
"Your text with <div>HTML Content</div>"