<div class="daic">
<p class="reward"></p>
<p class="reward"></p>
<p class="reward"></p>
<p class="reward"></p>
<p class="reward"></p>
</div>
<p class="data"></p>
var num = 1;
$('<p id="data' + num + '"></p>').appendTo('body');
获取变量id的属性id
console.log($('#data' + num).attr('id'));
给每个reward赋值id为rewardi
for(var i=0;i<6;i++) {标签:num,变量,nth,拼接,child,id From: https://www.cnblogs.com/zerozq/p/17628053.html
$('.daic .reward:nth-child(' + i + ')').attr('id','reward'+(i));
}