i am trying to store css values for transformations of multiple divs in a dictionary to access them when the div is clicked (the div id being the key of the dict).
my dictionary:
css_dict = {
'keyA' : ['10px, 15px', '20px', '10px'],
'keyB' : ['20px, 30px', '10px', '20px'],
'keyA' : ['30px, 55px', '25px', '30px'],
}
i need to access it like this (variable instead of the key):
css_dict.var[0]
jsFiddle of what im trying to do: /
i cant figure out or find the right syntax for this to work...
i am trying to store css values for transformations of multiple divs in a dictionary to access them when the div is clicked (the div id being the key of the dict).
my dictionary:
css_dict = {
'keyA' : ['10px, 15px', '20px', '10px'],
'keyB' : ['20px, 30px', '10px', '20px'],
'keyA' : ['30px, 55px', '25px', '30px'],
}
i need to access it like this (variable instead of the key):
css_dict.var[0]
jsFiddle of what im trying to do: http://jsfiddle.net/tKFka/25/
i cant figure out or find the right syntax for this to work...
Share Improve this question asked Jan 6, 2013 at 15:04 user1952949user1952949 571 gold badge1 silver badge3 bronze badges 2 |1 Answer
Reset to default 15Use []
instead of dot.
var var1 = 'keyA';
css_dict[var1][0];
css_dict[var][0]
. jsfiddle.net/tKFka/28 – Rikonator Commented Jan 6, 2013 at 15:06$
invar mykey="k", mydict={$mykey: 'value'}
– Sohail Si Commented Nov 27, 2018 at 19:25