0

Background,

There are some elements where CSS animations needs to be applied. However these CSS needs to be generated on the fly as calculation needs to be done from JavaScript code.

This question clarifies how to dynamically add a CSS. Now the question is, how do I remove or replace a CSS generated following the accepted answer?

Just to be clear, it's nothing to do with removing a class from element. I need to remove it from the page so that animations will stop from elements with class. At some time later I can alter the CSS and re-register class so that associated elements are animated in different way.

Community
  • 1
  • 1
Low Flying Pelican
  • 5,974
  • 1
  • 32
  • 43

4 Answers4

1

document.getElementById('someElementId').className = '';

0

Edit.

You can remove it from the element's class list

document.getElementById("myelementsid").classList.remove("classname");
Pablo Recalde
  • 3,334
  • 1
  • 22
  • 47
0

Here you are full documentation to do it with jQuery https://api.jquery.com/removeclass/ with this, you can remove one or more classes

Nenad Jovicic
  • 188
  • 1
  • 7
0

If you want to remove the specific style from the page you can do it like the following snippet:

$('link[title=stylesheettitle]').prop('disabled',true);

OR

$('link[title="stylesheettitle"]').remove();

Java Script

var style = document.getElementById('styleID');
style.parentNode.removeChild(style );
Afnan Ahmad
  • 2,492
  • 4
  • 24
  • 44
  • Thanks, but I don't want to change element, I need to remove the class, to stop css animations, and add it after an interval with different parameters (for example animation duration / no of pixels transformed/ etc...), and the class does not reside in a style sheet, it's added dynamically (see the linked question) – Low Flying Pelican Feb 10 '17 at 13:06
  • @LowFlyingPelican what did you try ? – Afnan Ahmad Feb 10 '17 at 13:12
  • @LowFlyingPelican this what you are looking for: http://stackoverflow.com/questions/7125453/modifying-css-class-property-values-on-the-fly-with-javascript-jquery – Afnan Ahmad Feb 10 '17 at 13:21