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);
})
我想知道,为什么该.append
命令不适用于+this
,但在创建 div 时它可以工作。我究竟做错了什么?对不起我的英语不好,提前非常感谢!
更新!
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);
}
});
});
像这样,所有值都附加在#player_stats_block00 中!我尝试了您的几个答案,但我无法将它们附加到正确的#player_stats_blockXX。再次抱歉我的英语不好,谢谢大家的帮助!