星期日, 4月 29, 2012

[jQuery API] Html encode decode

利用jQuery簡單的完成html的編碼跟解碼
function htmlEncode(value){
  return $('<div/>').text(value).html();
}

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

Reference:
JavaScript/jQuery HTML Encoding

沒有留言:

張貼留言

留個話吧:)

其他你感興趣的文章

Related Posts with Thumbnails