Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery通过一个方法传递多个变量_Jquery_Variables_Selector_Global - Fatal编程技术网

jQuery通过一个方法传递多个变量

jQuery通过一个方法传递多个变量,jquery,variables,selector,global,Jquery,Variables,Selector,Global,我不知道我是否遗漏了什么。我想通过相同的方法运行多个全局变量。见下文 $('#pageMain .stuff, #pageMain .postFooter').each(function(){ $(this).vertCenter(); }); 而是使用全局变量: $main, $titles, $footers 所以有点像 $($main, $titles, $footers).each(). . . 您需要对每个jQuery对象调用每个: $footers.each(funct

我不知道我是否遗漏了什么。我想通过相同的方法运行多个全局变量。见下文

$('#pageMain .stuff, #pageMain .postFooter').each(function(){
    $(this).vertCenter();
});
而是使用全局变量:

$main, $titles, $footers
所以有点像

$($main, $titles, $footers).each(). . .

您需要对每个jQuery对象调用
每个

$footers.each(function(){ ... });
$main.each(function(){ ... });
$titles.each(function(){ ... });
或者,您可以执行以下操作:

var aggregated = $footers.add($main).add($titles);

aggregated.each(function() { ... }); 

您需要对每个jQuery对象调用
每个

$footers.each(function(){ ... });
$main.each(function(){ ... });
$titles.each(function(){ ... });
或者,您可以执行以下操作:

var aggregated = $footers.add($main).add($titles);

aggregated.each(function() { ... }); 

但我正在尝试运行vertCenter();在每个主题上,技术上我不能说$footers.add($main)。add($titles)。each()?是的。不过,如果您计划不止一次使用聚合版本,我不会这么做……对,因为它必须运行sparkle()十亿次,但我正在尝试运行vertCenter();在每个主题上,技术上我不能说$footers.add($main)。add($titles)。each()?是的。不过,如果你打算不止一次地使用聚合版本,我不会这么做……对,因为这样它就必须运行sparkle()十亿次