for ( var i = 0; i < contentCount; i++ )
{
var farm_id = _newspaperData[i]['farm_id'];
//console.log(farm_id )
$('#news_item_' + i).html(
'<input type="hidden" value="' + farm_id + '" id="#news_item_farm_id_' + i + '" />' +
'<div class="author" style="position: absolute; top: 2px; left: 2px"></div>' +
'<div class="item" style="position: absolute; bottom: 2px; right: 2px">' +
'<div class="icon_' + _newspaperData[i]['product_varname'] + ' bg_64x64" style="position:relative; height: 90px;width: 120px;">' +
'<div class="stroke-shadow-black" style="position: absolute; top: 0; left: 10px; font-size: 30px">' + $.number( _newspaperData[i]['product_amount'] ) + 'x</div>' +
'<div class="stroke-shadow-black" style="position: absolute; bottom: 0; right: 10px; font-size: 22px">' + $.number( _newspaperData[i]['product_price'] ) + ' Coin</div>' +
'</div>' +
'</div>' ).click(function()
{
//console.log(farm_id )
new Roadside().getOtherRoadside(farm_id)
});
}
当我单击每个元素时,farm_id 值将与循环的最后一个相同。
似乎点击功能没有得到每个循环的farm_id值