As hinted at by SpaceBison, your browser will decode HTML-encoded values and write them out as 'plain-text' HTML.
In order to write the value out encoded, you will effectively have to 'double-encode' the value, so when the browser decodes and renders it, it will still be encoded once.
If your value originally comes from an ASP.NET MVC model property, or similar (assuming this based on your tags), you can use HttpUtility.HtmlEncode
in your server-side code, for example:
Model.Name = HttpUtility.HtmlEncode(Model.Name);
However, if you need to do this in the front-end, you can write a simple jQuery function to encode the value (shamelessly stolen from this answer):
function HtmlEncode(str) {
return String(str)
.replace(/&/g, '&')
.replace(/"/g, '"')
.replace(/'/g, ''')
.replace(/</g, '<')
.replace(/>/g, '>');
}
You can then do the following in your jQuery, before you add the item to your container:
Name = HtmlEncode(Name);
To see it in action: http://jsfiddle.net/Rb2VJ/1/