首页 > Web开发 > 详细

$().text() 和 $().html()

时间:2015-10-29 23:04:33      阅读:405      评论:0      收藏:0      [点我收藏+]

1:性能

stackflow:http://stackoverflow.com/questions/1910794/what-is-the-difference-between-jquery-text-and-html

demo:http://jsfiddle.net/PhJNX/

 

  • jQuery‘s .html() is ~2x faster than .text().
  • pure JS‘ .innerHTML is ~3x faster than .html().
  • pure JS‘ .nodeValue is ~50x faster than .html(), ~100x than .text(), and ~20x than .innerHTML.

2:安全

stackflow:http://stackoverflow.com/questions/9735045/is-jquery-text-method-xss-safe

demo:http://jsfiddle.net/TLu69/

$().text()更安全

$().text() 和 $().html()

原文:http://www.cnblogs.com/xnlc/p/4921933.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!