Skip to content Skip to sidebar Skip to footer

How To Remove Or Reset Css Style Using Js?

I want either remove or reset a style applied on a particular DOM node using JS. node.style.webkitTransitionDuration = '5000ms'; node.style.webkitTransformO

Solution 1:

If you are looking to remove the rule from the element then this should work:

node.style.webkitTransform = ''; 

Solution 2:

You say you don't want to use a framework. but if it is OK (according to your comment) to do so:

You can use jQuery:

so you can do in jQuery:

$('selector').css({
   webkitTransitionDuration = '5000ms',
   webkitTransformOrigin = '200px 200px',
   webkitTransform = 'rotateZ(25rad)'
})

you can clear out the style element with:

$('selector').attr('style','');

add class:

$('selector').addClass('newClass');

remove class:

$('selector').removeClass('rClass');

Post a Comment for "How To Remove Or Reset Css Style Using Js?"