Hi

Wonder how I can convert a string to a json array.

//start code

var arrCss = ["a___{'color':'red','font-weight':'bold'}", "h1,h2___
{'color':'blue'}"];

for(var i = 0; i < arrCss.length; i++){
   var snip = arrCss[i].split("___");
   $(snip[0]).css(snip[1]);
}

//end code


The problem is that .css() treats snip[1] as a string but I need it to
handle it as a json array.

Bad: .css("{'color':'red','font-weight':'bold'}");
Good: .css({'color':'red','font-weight':'bold'});

Any solution out there?

Thanks

Reply via email to