This works OK:
$(container_elm).css({
'border-width':'1px'
})
Now I am trying to pass CSS propertyName : value as a parameter to a function:
function my_func(css_arr) {
if (css_arr!==null && css_arr!=='') {
for(var x in css_arr) {
if(css_arr.hasOwnProperty(x)) {
y=css_arr[x];
x_new='"'+x+'"';
y_new='"'+y+'"';
$(container_elm).css({
//'border-width':'1px' // this works
//x:y // this does NOT work
//x_new:y_new // this does NOT work
});
//console.log(x_new, y_new); //returns "border-width" "1px"
//console.log(x, y); //returns border-width 1px
}
}
}
}
//usage
my_func({'border-width':'1px'});
How can I pass CSS object "propertyName : value", and make .css() receive it and work?
Edit
Demo - http://jsfiddle.net/BRwzF/5/
console.logs?