var collection = $('ul li');
collection.each(function (index) {
var test = $.extend($(this), {
// var test = $.extend(collection.eq(index), {
someProperty: 'val'
});
console.log(test.someProperty);
});
console.log(collection.eq(0).someProperty);
そしてテスト: http://jsfiddle.net/simo/G3yCr/1/
jquery コレクション内の各オブジェクトを拡張しようとしています。コレクション内の各アイテムから直接プロパティにアクセスしたい。
collection.eq(index)
問題は、オブジェクトが拡張されない理由です。コメント行は代替であり、同じ結果が得られます。