相关疑难解决方法(0)

'$(this)'的成本是多少?

这里的人经常建议缓存jQueryDOM元素创建的对象,就像使用以下代码一样:

$('#container input').each(function() {
    $(this).addClass('fooClass');
    $(this).attr('data-bar', "bar");
    $(this).css('background-color', 'red');
});
Run Code Online (Sandbox Code Playgroud)
  • 缓存jQuery对象真的能提高代码的性能吗?
  • 将DOM元素传递给jQuery构造函数时,"幕后"会发生什么?

javascript performance jquery

56
推荐指数
4
解决办法
3566
查看次数

标签 统计

javascript ×1

jquery ×1

performance ×1