I have a Javascipt object which I use as dictionary
var obj={
xxx:'1'
yyy:'2'
}
However –
xxx and yyy should be a jQuery object.
something like :
var obj =
{
$('#div1'):'1' ,
$('#div2'):'2'
}
is it possible ?
also, How can I get the “value” for key $('#div2') ?
p.s.
I the $.data cant help me here since its also a key value
and i need in the key – object Type also.
Object keys can only be strings ( or Symbol), period. See Member Operators – Property Names @ MDN.
Choose a reasonable string representation, and use that. In this case, I’d say the selector string looks like a decent choice:
Use one of the member operators, either dot notation
or bracket notation (more useful for property names not known until runtime):