user1710796
user1710796

Reputation:

Set css property without css transition

I have an element for which I need to toggle the opacity. Sometimes I want to transition the opacity, and sometimes I do not. Is there an easy way to reset the property without the transition using JavaScript some of the time without turning the transition off?

Upvotes: 4

Views: 1631

Answers (1)

C3roe
C3roe

Reputation: 96241

Is there an easy way to reset the property without the transition using JavaScript some of the time without turning the transition off?

Not that I know of. A transition occurs when the property it is set on changes – how that change occurs, does not matter.

But there is an easy way of turning it off – apply the transition via a class, and then remove that class dynamically when you want to change the property value without transition.

Upvotes: 6

Related Questions