My goal is to generate an array having multiple jsons in which different keys and values exist but, when I look in to generated array, I found same keys in each json.
Please look at the code below:
var jsonObjStyle = [];
var uniqueclass = '';
$("*", newObj).each(function (e) {
if($(this).attr('style')){
uniqueclass = 'class'+new Date().getTime();
jsonObjStyle.push({
uniqueclass:$(this).attr('style')
});
}
});
Generated array:
[{"uniqueclass":"left: 457.55px; top: 331px;"},{"uniqueclass":"height: auto; display: block;"},{"uniqueclass":"text-align: center;"},{"uniqueclass":"z-index: 1001;"}]
In every json, I found same key, uniqueclass
Can anybody please tell me where I am wrong?
Regards
In Javascript’s object literal syntax, object property names (“keys”) are literal. To use variable names, do something like: