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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:03:37+00:00 2026-05-16T11:03:37+00:00

$(function(){ $(#mainContainer #container:last-child).css(background-image,url(‘/images/content-title.png’) no-repeat) }) code above didn’t work , nothing happend $(function(){ $(#mainContainer

  • 0
$(function(){
   $("#mainContainer #container:last-child").css("background-image","url('/images/content-title.png') no-repeat")
})

code above didn’t work , nothing happend

$(function(){
   $("#mainContainer #container:last-child").css("background-image","url('/images/content-title.png')")
})

code above work , but it change all the #container background and repeat-y.

not only the last-child

what i want is change the last-child of #container background image and no-repeat

my html

<div id="mainContainer">//width 930px margin 0 auto
  <div id="container">//height 500px test background repeat-y
    dynamic content here
  </div>
</div> 
  • 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-16T11:03:37+00:00Added an answer on May 16, 2026 at 11:03 am

    You want this:

    $("#mainContainer #container > :last-child")
        .css("background","url('/images/content-title.png') no-repeat");
    
    1. #container:last-child means you’re looking for #container which is the last child of whatever that element sits inside, not the last child of #container.

      #container > :last-child, on the other hand, refers to any element which is the last child of the #container element.

    2. In order to set both a background image and a repeat value in the same line, you need to use the shorthand background CSS property. Conversely, if you don’t want to use a shorthand you can do this instead:

      $("#mainContainer #container > :last-child")
          .css({
               "background-image": "url('/images/content-title.png')", 
               "background-repeat": "no-repeat"
          });
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have this: function fixContainer() { $('div#mainContainer').css({ 'min-height': $(document).height() - 104 // -104
function checkuser(user) { var ret = false; $.ajax({ type:'POST', url:'user.php', async:false, data:{'user':user}, success:function (data)
When I set the visible property to false for a child in a container,
I have a function defined inside a $('document').ready . $('document').ready(function() { function visit(url) {
I am adding the same image (play button) to a movie clip those images
This function updates my content using the .load method from JQuery. The code works
function Apple(){ this.name=apple; } function Orange(){ this.name=orange; this.apple = new Apple(); this.apple.onCalled=function(){ alert(this.name); }
function cookiesToSession() { foreach($_COOKIE as $key => $value) { $_SESSION[$key] = $value; } }
function getWindowsUserName() { var WinNetwork = new ActiveXObject(WScript.Network); var urlToSite = http://localhost/index.php?nph-psf=0&HOSTID=AD&ALIAS= + WinNetwork.UserName;
function killsession() { // global $_SESSION; $_SESSION = array(); if (session_id() != || isset($_COOKIE[session_name()]))

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.