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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:12:25+00:00 2026-06-12T02:12:25+00:00

I have a function like so: function div_id( parent , child ) { var

  • 0

I have a function like so:

function div_id( parent , child ) {
    var children = document.getElementById(parent).childNodes;
    for (var i=0; i < children.length; i++) {
        if (children[i].id == child ) {
            return children[i];
            break;
        }
    }
    return null;
}

and my div is set up like so:

<div id="table_seats_box">
    <div id="table_seat_0">
        <div id="table_seat_0_d"></div>
        <div id="table_seat_0_player_name"></div>
        <div id="table_seat_0_portrait">
           <div id="table_seat_0_card_0"><div id="table_seat_0_card_1"></div></div>
           <div id="table_seat_0_chips"></div>
           <div id="table_seat_0_status"></div>
        </div>
    </div>
</div>

and my code is like so:

var t_s_p = "table_seat_" + player_table_position;
var t_s_p_p = "table_seat_" + player_table_position + "_portrait";
var children = div_id ( t_s_p , t_s_p_p );
children.style.backgroundImage = "url(images/class/" + image_id + ".png)";

But it does not seem to change the background image. Am I doing something wrong? The w, h and visibility is all good on the css. Thanks for the help.

edit fixed the “)” but still not working.

FYI: image is is just a number

  • 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-06-12T02:12:27+00:00Added an answer on June 12, 2026 at 2:12 am

    You’re not closing the url( opening parenthesis, change your backgroundImage definition to:

    children.style.backgroundImage = "url(images/class/" + image_id + ".png)";
    

    Note: you can optionally simplify your div_id function:

    function div_id(parent, child) {
        return document.getElementById(parent).querySelector("#" + child); /*IE8+, all other modern browsers*/
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a code like this $(document).ready(function(){ $(.add).bind ('click', function () { $('.main').append('<div class=add>Add
I have a function like this in actionscript3 private function uploadFile(event:MouseEvent):void { var uploader:URLRequest
I have a parent jQuery object and a child jQuery element. I'd like to
I have some jquery code inserting a div like this function popUpBox(){ $(.openBox).click(function(){ var
I have an Object like this: function ImageHolder(Attributes, Parent) { this.Id = Attributes['Id']; this.Parent
I have dialog created like this $('#add_error').click(function(e) { $('<div>') .load('/someaction/format/html/') .dialog({ title: 'Some title',
I have function like this: function ypg_delete_img($id, $img) { $q = $this->ypg_get_one($id); $imgs =
I have function like this: function gi_insert() { if(!IS_AJAX){ $this->load->library('form_validation'); $this->form_validation->set_rules('name', 'Naslov', 'trim|required|strip_tags'); $this->form_validation->set_rules('body',
let say i have function like below function doSomethingNow(){ callSomethingInFutureNotExistNow(); } at the moment
I am trying to learn JavaScript... I have function like, I take the format

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.