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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:39:55+00:00 2026-05-27T02:39:55+00:00

All, Here is my code for a script I am working on. WHAT IT

  • 0

All,

Here is my code for a script I am working on.

WHAT IT DOES:
When the blue button is pressed, a div should appear on top of the box containing the ‘5000’ number.

The problem I am having is with the usage of innerHTML & assigning an id to dynamically created div. I am not getting any errors in Firebug so am not sure what/ where I am going wrong.

The problem lines:

eCreditTransactions[i].id = ("trans" + i);

eCreditTransactions[i].innerHTML = '<div class="cCreditContainer"><span class="cCreditsNo">-50</span>&nbsp;<img class="cCurrency" src="" alt="" /></div><span class="cCloseMsg">Click box to close.</span><div class="dots"></div><div class="dots"></div><div class="dots"></div>';

And here is the full code:

var eCreditSystem = document.getElementById("creditSystem");
var i = 0;
var eCreditTransactions = new Array(6);                 // 6 instances created which will be recycled

function createCreditTransaction ()                 // func called when a transaction occurs, at the mo, attached to onclick()
{
    if (i < 6)
    {
        $(eCreditTransactions[i]).remove();
        eCreditTransactions[i] = undefined;                 // to delete the existing data in the index of array
        addingElements (i);                 // calling function
    } else
    if (i > 5 || eCreditTransactions[i] != undefined)
    {
        i = 0;
        $(eCreditTransactions[i]).remove();
        eCreditTransactions[i] = undefined;
        console.log(eCreditTransactions[i]);
        addingElements (i);
    }
}

function addingElements (arrayIndex)                    // func called from within the 'createCreditTransaction()' func
{
    console.log(eCreditTransactions[i]);
    eCreditTransactions[i] = $(document.createElement('div')).addClass("cCreditTransaction").appendTo(eCreditSystem);

// the problem area

    eCreditTransactions[i].id = ("trans" + i);
    eCreditTransactions[i].innerHTML = '<div class="cCreditContainer"><span class="cCreditsNo">-50</span>&nbsp;<img class="cCurrency" src="" alt="" /></div><span class="cCloseMsg">Click box to close.</span><div class="dots"></div><div class="dots"></div><div class="dots"></div>';

    console.log(eCreditTransactions[i]);
    return i++;
}

Jsfiddle

  • 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-27T02:39:56+00:00Added an answer on May 27, 2026 at 2:39 am

    in this line of your code:

     eCreditTransactions[i] = $(document.createElement('div'))
    

    you are creating a dom element and then wrapping it in a jQuery object

    to access an id attribute on that object you need to use its methods

     eCreditTransactions[i].attr('id', 'newId');
    

    the same for innerHTML property

    use jQuery method html();

     eCreditTransactions[i].html(yourHtmlString);
    

    see here docu

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

Sidebar

Related Questions

Here is the code: <?php //Starting session session_start(); //Includes mass includes containing all the
Here is te code: <?php //Starting session session_start(); //Includes mass includes containing all the
enter code here Hi All, I have a simple windows service application that connects
Here is an example of my code in a DAL. All calls to the
Hey all. Here is the scenario. I have the below code, and I'm needing
It is Hallowe'en after all. Here's the problem: I'm maintaining some old-ish J2EE code,
I would like to select all jquery UI button that live inside all <div>
I'm currently working on a PHP/MySQL script that does the following, in this order:
I have been working on getting a python CGI script to work all day,
Here is whats happening (Code Block Below): I am working on a simple drop-down

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.