“jQuery unescape html” Kode Jawaban

jQuery unescape html

<script>
var encodedStr = "This is fun &amp; stuff";
var decoded = $("<div/>").html(encodedStr).text();
console.log(decoded);
</script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div/>
Undefined

jQuery unescape html

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

console.log(decodeEntities('1 &amp; 2')); // '1 & 2'
Shadow

jQuery unescape html

var encodedStr = "This is fun &amp; stuff";
var decoded = $("<div/>").html(encodedStr).text();
console.log(decoded);


<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div/>
Shadow

Jawaban yang mirip dengan “jQuery unescape html”

Pertanyaan yang mirip dengan “jQuery unescape html”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya