How to decode HTML entities using jQuery?

后端 未结 19 2183
忘了有多久
忘了有多久 2020-11-21 23:21

How do I use jQuery to decode HTML entities in a string?

相关标签:
19条回答
  • 2020-11-22 00:08

    Security note: using this answer (preserved in its original form below) may introduce an XSS vulnerability into your application. You should not use this answer. Read lucascaro's answer for an explanation of the vulnerabilities in this answer, and use the approach from either that answer or Mark Amery's answer instead.

    Actually, try

    var decoded = $("<div/>").html(encodedStr).text();
    
    0 讨论(0)
提交回复
热议问题