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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:29:34+00:00 2026-05-13T07:29:34+00:00

Lets say I have two divs How do I use .find to get div1’s

  • 0

Lets say I have two divs

How do I use .find to get div1’s background image, than apply that background image to div2, and replace “.jpg” with “_highlighted.jpg” ?

var div2bg = $('.div1').find('div').attr('background-image'??)//how to assigned the background image as a variable?

$('.div2').css("background-image", "url(" + div2bg + ")");
$('.div2').css("background-image").replace(".jpg", "_highlighted.jpg");
  • 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-13T07:29:35+00:00Added an answer on May 13, 2026 at 7:29 am

    Close but replace returns a string, it doesn’t change the source.

    I think you want this instead:

    var div2bg = $('.div1').css('background-image');
    
    $('.div2').css("background-image", div2bg.replace(".jpg", "_highlighted.jpg"));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

lets say i have two pages links.html & contents.php ... first page contains only
Lets say I have two types of documents stored in my CouchDB database. First
lets say i have two view controllers, firstViewController and secondViewController. The firstViewController is supposed
Lets say I have two projects A and B. A depends on B. I
Lets say you have a relational DB table like INVENTORY_ITEM. It's generic in the
Suppose I have table with two columns. I can center this table by using:
If I have two sequences and I want to process them both together, I
Answerers: How does one literally detect the user's font scale, so that it may
Is there a way to select an element with CSS based on the value
I've read the http://robmensching.com/blog/posts/2003/10/18/Component-Rules-101 blogpost which is very enlightning. However, I still have some

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.