Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
不知道我是否在这里遗漏了什么。我想通过相同的方法运行多个全局变量。见下文
$('#pageMain .stuff, #pageMain .postFooter').each(function(){ $(this).vertCenter(); });
而是使用全局变量:
$main, $titles, $footers
所以像...
$($main, $titles, $footers).each(). . .
您需要调用each每个 jQuery 对象:
each
$footers.each(function(){ ... }); $main.each(function(){ ... }); $titles.each(function(){ ... });
或者,您可以执行以下操作:
var aggregated = $footers.add($main).add($titles); aggregated.each(function() { ... });