.container可以包含许多.components,而.components本身可以包含.containers(反过来可以包含.components等).
给出这样的代码:
$(".container .component").each(function(){
$(".container", this).css('border', '1px solid #f00');
});
Run Code Online (Sandbox Code Playgroud)
我需要添加到大括号内的行,以便只选择CSS中宽度设置为"auto"的嵌套.container?我确信它很简单,但我还没有真正使用过jQuery.