用jquery實現HtmlEncode與HtmlDecode

ly5156發表於2012-06-01

I use these functions:

function htmlEncode(value){
  return $('<div/>').text(value).html();
}

function htmlDecode(value){
  return $('<div/>').html(value).text();
}

Basically a div element is created in memory, but it is never appended to the document.

 

相關文章