Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 901667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:35:31+00:00 2026-05-15T15:35:31+00:00

I haven’t seen any docs saying jQuery can change any CSS definition such as

  • 0

I haven’t seen any docs saying jQuery can change any CSS definition such as changing

td { padding: 0.2em 1.2em }

to

td { padding: 0.32em 2em }

but either have to change a whole style sheet, or change class of each element, or change css of each element.

Is changing the style definition possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T15:35:32+00:00Added an answer on May 15, 2026 at 3:35 pm

    There is DOM access to stylesheets, but it’s one of those things we tend to avoid because IE needs a load of compatibility cruft.

    A better way would be typically be to trigger the change indirectly, using a simple class change on an ancestor:

    td { padding: 0.2em 1.2em }
    body.changed td { padding: 0.32em 2em }
    

    Now just $('body').addClass('changed') and all the tds update.

    If you really must frob the stylesheets:

    var sheet= document.styleSheets[0];
    var rules= 'cssRules' in sheet? sheet.cssRules : sheet.rules; // IE compatibility
    rules[0].style.padding= '0.32em 2em';
    

    This assumes that the td rule in question is the first rule in the first stylesheet. If not, you might have to go searching for it by iterating the rules looking for the right selectorText. Or just add a new rule to the end, overriding the old one:

    if ('insertRule' in sheet)
        sheet.insertRule('td { padding: 0.32em 2em }', rules.length);
    else // IE compatibility
        sheet.addRule('td', 'padding: 0.32em 2em', rules.length);
    

    jQuery itself doesn’t give you any special tools to access stylesheets, but it’s possible there are plugins that might.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I haven't seen any questions relating to GNU autoconf/automake builds, but I'm hoping at
Haven't seen many Geneva related questions yet, I have posted this question in the
I have a jquery bug and I've been looking for hours now, I can't
Haven't found in docs. Does java ResultSet supports query arguments,like jdbcTemplate? For example, something
Haven't seen this feature anywhere else. I know that the 32nd bit is used
I haven't seen this datetime format before: 2010-08-19T16:09:07.08 The nearest I have found in
I haven't deployed the application yet. I'm new to this, how can i create
Haven't found this in my search on Stackoverflow - I know I've seen a
I haven't made any thorough analysis of which implementation of PHP is the best
I haven't found any information on MSDN regarding this problem. If we create an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.