0

Is it possible to modify a page's CSS using jQuery (not element but global css)?

For example I have a CSS entery of:

.page.left {
    top: -100%;
}

in my main stylesheet and I would like to modify it in runtime to top: -50% is it possible? again, it may be that this style may or may not been applied to any elements...

??

Thanks,

Sean.

0

2 Answers 2

1

The following code will do what you're asking for:

$('.page.left').css('top', '-50%');

It will find all (if any) elements on the page with both classes page and left and apply the new top style to them.

Sign up to request clarification or add additional context in comments.

Comments

0

You can use the same css selector to set the rules for these elements using jquery.

Example CSS rule:

.page.left {
  top: -100%;
}

In Jquery it would be:

$(".page.left").css("top","-100%");

but this will change only on the page where above line is executed.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.