将jQuery选择器缓存到新函数调用

时间:2016-02-26 15:08:07

标签: javascript jquery

我对此案例的变量分配有疑问:

function one() {
    $('div').each(function() { 
      var $this = $(this);

      two($this);
    });
}

function two(el) {
  var $el = el; // does this assignment save resources

  $el.somemethod();
  $el.someothermethod();
}

我是否需要将传递的元素重新分配给新变量,以便再次为two()缓存它?或者它根本没有任何区别。

0 个答案:

没有答案