Javascript String html()
// html escape a string String.prototype.html = function () { var string = new String(this); string = string.replace(/\&/g, "&"); string = string.replace(/\</g, "<"); string = string.replace(/\>/g, ">"); string = string.replace(/"/g, """) string = string.replace(/'/g, "'"); //from w w w . j a v a 2 s. c o m return string }
String.prototype.html = function() { return $('<i></i>').text(this).html(); };