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

  • Home
  • SEARCH
  • 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 6206271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:25:18+00:00 2026-05-24T05:25:18+00:00

Hi i am trying to apply a background image to a div using jquery.

  • 0

Hi i am trying to apply a background image to a div using jquery. The code i use works fine in all browsers except IE 6 and 7 (the weakest browsers i need to support). If I statically apply a style tag to my div, it does show the image but when i apply it using jquery it does not. I am using IE Tester to test in IE 6 and 7. When I look at the interpreted source code it shows a style attribute with the correct background property on the correct tag.

here is the code i use

HTML:

<div class="overlay">

JQuery:

var img-src = 'url('+$('.img-src').text()+')';
$('.overlay').css('background-image', img-src);

note: i’ve also tried using the key ‘backgroundImage’ instead of ‘background-image’ as a parameter to the css function. Using background-image is what got it to appear in IE 8. Has anyone faced a similar problem and know a work around?

UPDATE: The image i am trying to make appear actually does appear in IE 6, now it’s just IE 7 that’s giving me trouble.

  • 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-24T05:25:19+00:00Added an answer on May 24, 2026 at 5:25 am

    Try this

    $('.overlay').css('background-image', $('.img-src').text());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to achive a fullscreen background image inside a div using JQuery.
I am using CSS to apply a background image to a div tag that
I'm trying to add a custom image as a background for my application using
I'm trying to apply styles to all my divs, except one specific. I'm doing
I am trying to apply a background image hover effect on each row in
I am trying to apply a background-image to a li element. <ul> <li class=maintablink>&nbsp;</li>
I'm trying to create a CSS3 button which includes an image using multiple background.
I'm trying to set up an UIButton background using a stretchable image in Interface
Im trying to apply different background color to even and odd items in a
I am trying to apply some transformations on images using a CGContextRef. I am

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.