Is it possible to use a jQuery element object as an array/object key?
Example:
var el = jQuery(this);
var test = {};
test[el] = "something strange";
Doing a:
jQuery.each(test, function(k,v){
console.log(k);
});
just reports [object Object]
Is there a say that I could actually re-use the k as the original jQuery element object?
No, that is not possible.
ECMAscript only allows for
stringsas key-values for objects.What you could do instead, is to use the
id valuefrom a single node instead. So it might look likeThat of course requires the node to have an id value.