var els = [];
els.push($("#something"));
我需要将其添加到数组中,因为 #something 的属性将被更改,并且我需要获取它的原始属性(高度、宽度位置等)
我现在如何使用 els 数组中的元素?
最佳答案
如果只需要几个属性,我不会存储整个对象。
$something = $('#something');
els[$something.attr('id')] = {
width: $something.width(),
height: $something.height(),
offset: $something.offset() };
console.log(els['something']);
关于javascript - 将元素存储在数组中,然后在 jquery 中使用它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17513007/