我正在尝试访问嵌套循环中的元素。我已经使用 $(this) 很好地访问了第一个循环的循环元素,但是无法使用 $(this) 访问 secnod 元素。如何访问第二个元素?
$('.buttons').each(function(){
width = 100 / $(this).length;
$(this).each(function () {
$(this).width = width + '%';
});
});
上面的代码设置了第一个循环的第一个循环元素,而不是内部循环元素。