How to decode HTML entities using jQuery?

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

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

19条回答
  •  耶瑟儿~
    2020-11-21 23:55

    The question is limited by 'with jQuery' but it might help some to know that the jQuery code given in the best answer here does the following underneath...this works with or without jQuery:

    function decodeEntities(input) {
      var y = document.createElement('textarea');
      y.innerHTML = input;
      return y.value;
    }
    

提交回复
热议问题