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 3989878
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:25:38+00:00 2026-05-20T06:25:38+00:00

I have a page with a number of features and styles defined through jQuery

  • 0

I have a page with a number of features and styles defined through jQuery on document-ready and window-scroll, and even made sure it degraded nicely with JavaScript disabled. However, I was just throwing together a “print” stylesheet that scraps most of the stylizations, and when I tested it I realized that my jQuery methods are kicking in when printing and adding back in some background images. Is it possible to disable JavaScript or jQuery, or even a particular function, when printing?

The biggest problem is this piece, that generates a random background image based on a number generated earlier…it is overriding my print stylesheet’s call for background-image:none, even when using the !important tag:

$(document).ready(function() {
    $("body").css({backgroundImage: 'url(images/body_bg_'+background+'.jpg)'});
});

Thanks!

  • 1 1 Answer
  • 1 View
  • 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-20T06:25:38+00:00Added an answer on May 20, 2026 at 6:25 am

    Define your styles in the stylesheet. Then use JavaScript to change the DOM to cause those styles to be applied to an element, instead of modifying the style property.

    This lets you keep control of the different media, and maintain the separation of concerns (semantics, presentation and logic).

    @media screen {
       body.something {
           background-image: url(images/body_bg_something.jpg);
       }
    }
    
    $(document).ready(function() {
        $("body").addClass('something');
    }
    

    That said:

    it is overriding my print stylesheet’s call for background-image:none, even when using the !important

    It really shouldn’t be able to do that.

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

Sidebar

Related Questions

I have a page that has a large image on it with a number
I have two tables, one contains the page/heading number and the heading text, the
I have an asp page in which the are number of listboxes.I want to
In a simple html page I have: <SCRIPT> function Clicker(number){ if (number == 1)
I have a number of iframes calling a function in my main page. Is
I have a number of elements on a web page, that are scattered, meaning
I have n number of select elements in an html page that are used
I have a number of dropdowns and divs that are hidden when the page
I currently have an advanced search page that searches a number of fields in
I have a hyperlink in my page. I am trying to automate a number

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.