0

I wanted to know if there was a way to enable a CSS class without overriding the CSS I have tried

$("#remote1").click(function() {
           $("#navigation").css({"background":"black");
});

Which did most the work but I need to enable a CSS class so I can make an animation with CSS3 instead of Jquery as the animation I am attempting is best done with CSS3. How can I do that?

**Edited.. -.- **

How can I "activate" existing CSS in a CSS file remotely with Jquery

4
  • 2
    You can use addClass and removeClass. Commented Dec 10, 2015 at 2:30
  • 4
    you are missing } in .css Commented Dec 10, 2015 at 2:32
  • Please, provide more information(HTML, CSS, Jsfiddle and etc) Commented Dec 10, 2015 at 3:36
  • What I want utimately is do activate existing CSS NOT override it. If it is possible to disable one CSS file and enable another CSS file that would be even better Commented Dec 10, 2015 at 3:46

1 Answer 1

1

If you wants to dynamically add or remove classes, you can do it like:

$("#remote1").click(function() {
    $("#navigation").addClass("myclass");
});

Remove

$("#navigation").removeClass("myclass");

If wants to check if class is already added:

if ($("#navigation").hasClass("myclass")) {
    //if already have class added
}
Sign up to request clarification or add additional context in comments.

1 Comment

how about .toggleClass() ?