jQuery 性能优化与调试技巧
1. 快速加载表格
在处理包含 1000 条姓名和地址的 JSON 数据并使用 jQuery 创建表格时,在 IE 7 中创建表格可能需要 5 - 10 秒,这还不包括下载时间。
问题代码示例 :
// Return a sanitized version of text with & < > escaped for HTML
function esc( text ) {
return text
.replace( '&', '&' )
.replace( '<', '<' )
.replace( '>', '>' );
}
$(document).ready( function() {
function fillTable( names ) {
$.each( names, function() {
$('<tr>')
.append( $('<td>').addClass('name').html(
esc(this.first) + ' ' + esc(this.last)
) )
.append( $('<td>').addClass('address').html(
超级会员免费看
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



