用jquery实现HtmlEncode与HtmlDecode

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.

 

你可能感兴趣的:(jquery,function,div)