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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:18:14+00:00 2026-06-03T08:18:14+00:00

var positions = [ 00, 01, 02, 03, 04, 05 ]; jQuery.each( positions, function(players)

  • 0
var positions = [ "00", "01", "02", "03", "04", "05" ];
jQuery.each( positions, function(players) {
var playerNotesContent = document.createElement('div');
playerNotesContent.setAttribute('id', 'player_stats_block'+this);
$("#player_stats_block" + this).append (columns); 
})

I would like to know, why the .append command doesn’t work with the +this, but while creating div it works. What am I doing wrong? Sorry for my bad English and thanks a lot in advance!

UPDATED!

var positions = [ "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18" ];

jQuery.each( positions, function(players, value) {

var player_id = $("#ctl" + value).attr("href").match(RegExp('players/([^/]+)/details.php$'))[1];
var playerlink = document.getElementById("ctl" + value);

GM_xmlhttpRequest({
method: 'GET',
url: 'http://www.test.com/players/item/' + player_id,
onload: function(responseDetails) 
{
            var page = jQuery(responseDetails.responseText);
            var columns = jQuery('div.columns',page);
            var playerNotesContent = document.createElement('div');
            playerNotesContent.setAttribute('id', 'player_stats_block'+value);
            playerlink.parentNode.insertBefore( playerNotesContent, playerlink.nextSibling  );
            $('#player_stats_block00').append (columns); 
}
});
});

Like this all values gets appended in #player_stats_block00! I tried several of your answers but i cant get them appended to their correct #player_stats_blockXX. Sorry again for my bad english and thank you all for your help!

  • 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-03T08:18:16+00:00Added an answer on June 3, 2026 at 8:18 am

    Your code is creating a div and setting its id, and then trying to look up that div by that ID. The lookup will fail, because the div hasn’t been added to the DOM anywhere yet.

    var positions = [ "00", "01", "02", "03", "04", "05" ];
    
    jQuery.each( positions, function(players) {
        // Here you're creating the div
        var playerNotesContent = document.createElement('div');
    
        // ...and setting its `id` (btw, you can just do playerNotesContent.id = value;)
        playerNotesContent.setAttribute('id', 'player_stats_block'+this);
    
        // ...and here trying to look it up
        $("#player_stats_block" + this).append (columns); 
    });
    

    If you’re trying to append the div to columns, you probably want this instead of your last line:

    columns.append(playerNotesContent);
    

    (Note that append adds content to the container you call it on.)

    That assumes columns is a jQuery object. Otherwise:

    $(playerNotesContent).appendTo(columns);
    

    or

    $(columns).append(playerNotesContent);
    

    (Note that appendTo adds the content you call it on to the argument you give it; it’s the converse of append.)

    It’s also worth noting that the divs being created have no content, so unless you’re styling them, they won’t have any dimensions and will be kinda hard to find on the page. 🙂

    Here’s an example assuming columns is a jQuery object, and giving the divs some content so you can see them: Live copy | source

    HTML:

    <div id="columns"></div>
    

    JavaScript:

    jQuery(function($) {
    
      var columns = $("#columns");
      var positions = [ "00", "01", "02", "03", "04", "05" ];
    
      jQuery.each( positions, function(players) {
        var playerNotesContent = document.createElement('div');
        playerNotesContent.innerHTML = "Player Stats";
        playerNotesContent.id = 'player_stats_block'+this;
        columns.append(playerNotesContent);
      });  
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jQuery flot chart with this code: $(table.statics).each(function() { var colors =
I have the following piece of code: jQuery.fn.shake = function(intShakes, intDistance, intDuration) { this.each(function()
I have this script using jquery: $(document).ready(function() { $('.fotky,.video,.diskusia,.onas,.zbrane,.akcie,.tabroz,.tabburk,.tabhil,.tablest').append('<span class=hover></span>').each(function () { var $span
this plugin elastic, (function (jQuery) { jQuery.fn.extend({ elastic: function () { var mimics =
var thumbs = document.getElementsByTagName(img); for (var i=0; i<thumbs.length; i++) { Core.addEventListener(thumbs[i], click, function() {alert(i);});
var UI$Contract$ddlForm_change = function() { //'this' is currently the drop down that fires the
I'm having a problem with this jQuery function, the portion of the function that
i am using textarea elastic plugin JQuery. this is the plugin (function(jQuery){ jQuery.fn.extend({ elastic:
So, I have this jQuery .each loop, and for the most part its working
I've followed the code on this link : Using jQuery to center a DIV

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.