如果要將值寫進html中就必須做HTML encode,jQuery可以簡單的做到encode與decode的效果
function HTMLEncode(str) { //建立一個在memory中的div,寫入值,並以html()方式取出 return $('').text(str).html(); } function HTMLDecode(str) { //與Encode相反 return $('').html(str).text(); }
Categories: jQuery