如何有效地与追加内容的JQuery [英] how to efficiently append content with JQuery

查看:156
本文介绍了如何有效地与追加内容的JQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用JQuery追加大量标签里面的文字。我发现标签上的慢追加是在目前更多的文字,以及大量的文字实在是太慢了。

I am using JQuery to append large amounts of text inside a tag. I find the more text currently within the tag the slower appending is, and for large amounts of text it is too slow.

有没有追加文本更有效的方法?如例如创造虚设子标记和设置它们的内容,而不是附加到母体

Is there a more efficient way to append text? Such as for instance creating dummy child tags and setting the content of them rather than appending to the parent?

推荐答案

勾选此 presentation 而这其中也: jQuery的反模式结果
而在一般情况:

Check this presentation and this one too: jQuery Anti-Patterns
And in general:


  • 请不要.append()的循环

  • 请不要直接追加到DOM

  • 建立一个字符串,不是附加或使用的DocumentFragment

  • 请不要直接追加到DOM

这篇关于如何有效地与追加内容的JQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆