i have a object dom which have a property named changeCss which changes the css on any element: the code is as follows:
var Dom = {
changeCss : function(element, properties){
if(typeof (properties) === "object"){
var properties_name = Object.keys(properties),
properties_value = [];
for ( var i = 0; i < properties_name.length ; i++ ){
var a = properties_name[i],
b = properties[a];
properties_value[i] = b;
element.setAttribute("style", a+":" + b+";");
};
}else{
throw 'properties of '+ element +" should be object";
}
},
}
so from this code you will be understand how i want to change the css of any element,and this is working perfectly. But the problem which i am facing is that if i am writing this code:
var x = document.getElementById("some_html_tag_id");
Dom.changeCss(x, {"width": "100px", "height":"80px"});
then the style element only consist height:80px not width:100px ! how to add all these style properties?
thanks
anni