var arr = [];
$('#menu').children().each(function(){
arr = $(this).width();
});
console.log(arr);
这样不行,为什么? 我怎样才能让它工作,以便元素属性可以缓存在数组中以供以后使用?
最佳答案
var arr = [];
$('#menu').children().each(function(){
arr.push($(this).width())
});
console.log(arr);
关于javascript - jQuery 收集数组中的元素属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8585787/