zazvorniki
zazvorniki

Reputation: 3602

Removing value from Object

I have an object that I am trying to remove from a cssProperty that is being passed to an element. I have tried several things with no luck and am at a loss.

The object looks like

Object {background-color: "#91eae8"}

and I have tried removing it like

delete this.cssProps.background-color;

delete this.cssProps[background-color];

delete this.cssProps['background-color'];

neither has worked and throws viewModel errors because it doesn't know what I'm doing. I cannot change how the object comes in to have quotes around it or anything similar.

Upvotes: 0

Views: 70

Answers (1)

Thomas Devries
Thomas Devries

Reputation: 889

In css there is no such thing as an undefined property. They all have default values. So trying to remove a property doesn't work. Instead you can change the value to a different value to get the behavior you want.

I would try doing one of these

this.style.backgroundColor = "inherit";//background will be the same as it's parent
this.style.backgroundColor = "transparent";//background will show what is behind it
this.style.backgroundColor = "inital"; //sets it to the default value

Upvotes: 2

Related Questions