Unescape HTML entities in Javascript?

前端 未结 30 2924
野趣味
野趣味 2020-11-21 05:40

I have some Javascript code that communicates with an XML-RPC backend. The XML-RPC returns strings of the form:


30条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-21 05:58

    If you're using jQuery:

    function htmlDecode(value){ 
      return $('
    ').html(value).text(); }

    Otherwise, use Strictly Software's Encoder Object, which has an excellent htmlDecode() function.

提交回复
热议问题