$.each(res.ZdjList,function(gid,gdata){
  gpHtml += '<div class="tab-list">'+
                        
                         '<ul id="myul">'+
                            '<a href="#?Mid='+gid+'" class="join_se">'+
                            '<li id="gy-qishu" class="gy-qishu">'+gdata.yearnum+'</li>'+
                            '<li id="gy-diqu" class="gy-diqu">'+gdata.RegionName+'</li>'+
                            '<li id="gy-clmc" class="gy-clmc" style="padding-left:0; width:250px;">'+gdata.clmc+'</li>'+
                            '<li id="gy-tzsx" class="gy-tzsx" style="width:250px;">'+gdata.tzsx+'</li>'+
                            '<li id="gy-dw" class="gy-dw">'+gdata.danwei+'</li>'+
                            '<li id="gy-zdj" class="gy-zdj">¥'+gdata.zhidaojia+'</li>'+
                            '<div style="clear:both; float:none;"></div>'+
                            '</a>'+
                            '</ul>'+
                        
                        '</div>';
$('#news2017').on('click','ul a.join_se',function(e){
     e.preventDefault();

var join_se = $('.join_se').html();
var yearnum = $('#gy-qishu').html();
var RegionName = $('#gy-diqu').html();
var clmc = $('#gy-clmc').html();
var tzsx = $('#gy-tzsx').html();
var danwei = $('#gy-dw').html();
var zhidaojia = $('#gy-zdj').html();
     var html = 
'<div class="model_join">'+
                    '<div class="model_box">'+
'<div>'+
                        '<h2>指导价</h2>'+
'</div>'+
'<div style="clear:both;padding-top:20px">'+
                 '<table style="width:490px; " border="1px" cellspacing="0" cellpadding="0">'+ 
'<tr>'+
'<td style="width: 30px; height: 40px; text-align: right; font-size: 13px; font-weight:  bold">材料名称:</td> '+
'<td style="width: 100px; height: 40px; text-align: center; word-break:break-all; font- size: 13px; color:red" colspan="3">'+clmc+'</td>'+  
'</tr>'+ 
'<tr>'+ 
'<td style="width: 30px; height: 40px; text-align: right; font-size: 13px; font-weight:  bold">期数:</td>'+ 
'<td style="width: 50px; height: 40px; text-align: center; font-size:  13px">'+yearnum+'</td>'+ 
'<td style="width: 30px; height: 40px; text-align: right; font-size: 13px; font-weight:  bold">地区:</td>'+ 
'<td style="width: 50px; height: 40px; text-align: center; font-size:  13px">'+RegionName+'</td>'+
'</tr>'+ 
'<tr>'+ 
'<td style="width: 30px; height: 40px; text-align: right; font-size: 13px; font-weight:  bold">特征属性:</td>'+ 
'<td style="width: 100px; height: 40px; text-align: center; word-break:break-all; font- size: 13px"  colspan="3">'+tzsx+'</td>'+  
'</tr>'+
'<tr>'+ 
'<td style="width: 30px; height: 40px; text-align: right; font-size: 13px; font-weight:  bold">单位:</td>'+ 
'<td style="width: 50px; height: 40px; text-align: center; font-size:  13px">'+danwei+'</td>'+ 
'<td style="width: 30px; height: 40px; text-align: right; font-size: 13px; font-weight:  bold">指导价:</td>'+ 
'<td style="width: 50px; height: 40px; text-align: center; font-size:  13px">'+zhidaojia+'</td>'+
'</tr>'+ 
'</table>'+
'</div>'+
                        '<div style="text-align: center" class="imgUpdata_btn_box">'+
                        '<input type="button" class="join_close" value="关闭">'+    
                        '</div>'+
                    '</div>'+
                '</div>';
     $('body').append(html);
});
  });
我想通过点击a标签做div弹出层,可是现在每次都只获取第一条信息,无法获取到我点击的数据,请大神们帮帮忙

解决方案 »

  1.   

    $.each(res.ZdjList,function(gid,gdata){
      gpHtml += '<div class="tab-list">'+
                            
                             '<ul id="myul">'+
                                '<a href="#?Mid='+gid+'" class="join_se">'+
                                '<li id="gy-qishu" class="gy-qishu">'+gdata.yearnum+'</li>'+
                                '<li id="gy-diqu" class="gy-diqu">'+gdata.RegionName+'</li>'+
                                '<li id="gy-clmc" class="gy-clmc" style="padding-left:0; width:250px;">'+gdata.clmc+'</li>'+
                                '<li id="gy-tzsx" class="gy-tzsx" style="width:250px;">'+gdata.tzsx+'</li>'+
                                '<li id="gy-dw" class="gy-dw">'+gdata.danwei+'</li>'+
                                '<li id="gy-zdj" class="gy-zdj">¥'+gdata.zhidaojia+'</li>'+
                                '<div style="clear:both; float:none;"></div>'+
                                '</a>'+
                                '</ul>'+
                            
                            '</div>';
    $('#news2017').on('click','ul a.join_se',function(e){
         e.preventDefault();var join_se = $('.join_se').html();
    var yearnum = $('#gy-qishu').html();
    var RegionName = $('#gy-diqu').html();
    var clmc = $('#gy-clmc').html();
    var tzsx = $('#gy-tzsx').html();
    var danwei = $('#gy-dw').html();
    var zhidaojia = $('#gy-zdj').html();
         var html = 
    '<div class="model_join">'+
                        '<div class="model_box">'+
    '<div>'+
                            '<h2>指导价</h2>'+
    '</div>'+
    '<div style="clear:both;padding-top:20px">'+
                     '<table style="width:490px; " border="1px" cellspacing="0" cellpadding="0">'+ 
    '<tr>'+
    '<td style="width: 30px; height: 40px; text-align: right; font-size: 13px; font-weight:  bold">材料名称:</td> '+
    '<td style="width: 100px; height: 40px; text-align: center; word-break:break-all; font- size: 13px; color:red" colspan="3">'+clmc+'</td>'+  
    '</tr>'+ 
    '<tr>'+ 
    '<td style="width: 30px; height: 40px; text-align: right; font-size: 13px; font-weight:  bold">期数:</td>'+ 
    '<td style="width: 50px; height: 40px; text-align: center; font-size:  13px">'+yearnum+'</td>'+ 
    '<td style="width: 30px; height: 40px; text-align: right; font-size: 13px; font-weight:  bold">地区:</td>'+ 
    '<td style="width: 50px; height: 40px; text-align: center; font-size:  13px">'+RegionName+'</td>'+
    '</tr>'+ 
    '<tr>'+ 
    '<td style="width: 30px; height: 40px; text-align: right; font-size: 13px; font-weight:  bold">特征属性:</td>'+ 
    '<td style="width: 100px; height: 40px; text-align: center; word-break:break-all; font- size: 13px"  colspan="3">'+tzsx+'</td>'+  
    '</tr>'+
    '<tr>'+ 
    '<td style="width: 30px; height: 40px; text-align: right; font-size: 13px; font-weight:  bold">单位:</td>'+ 
    '<td style="width: 50px; height: 40px; text-align: center; font-size:  13px">'+danwei+'</td>'+ 
    '<td style="width: 30px; height: 40px; text-align: right; font-size: 13px; font-weight:  bold">指导价:</td>'+ 
    '<td style="width: 50px; height: 40px; text-align: center; font-size:  13px">'+zhidaojia+'</td>'+
    '</tr>'+ 
    '</table>'+
    '</div>'+
                            '<div style="text-align: center" class="imgUpdata_btn_box">'+
                            '<input type="button" class="join_close" value="关闭">'+    
                            '</div>'+
                        '</div>'+
                    '</div>';
         $('body').append(html);
    });
      });这是代码