1:性能
stackflow:
demo:
- jQuery's
.html()is ~2x faster than.text(). - pure JS'
.innerHTMLis ~3x faster than.html(). - pure JS'
.nodeValueis ~50x faster than.html(), ~100x than.text(), and ~20x than.innerHTML.
2:安全
stackflow:
demo:
$().text()更安全