是这样,我的table是通过后台参数动态生成的,但是生成的行上绑定的函数进行遍历时获取不到表格的数据,但是我通过tr的id却可以,求解,求大神降临,求大神help谢谢谢谢!

解决方案 »

  1.   

    function startUp(){
    //str += id+"-"+Org_Name+"-"+Class+"-"+Parent_OrgName+",";
    var layList1 = '${CcpOrgList}';
    if(layList1 != "" && layList1 != null){
    var topInfo = layList1.split(",");  
    for(var i=0;i<topInfo.length;i++){
    var infos = topInfo[i].split("-");
    var id = infos[0];
    var Org_Name = infos[1];
    var distance = infos[2]*30;
    var Parent_OrgName = infos[3];

      if(infos[2]< 4){
    var html = "<tr id='"+id+"'><td style='font-size:15px;height:15px;width:220px;padding-top:5px;padding-left:"+distance+"px;' onclick='changeIt(\""+id+"\","+infos[2]+");'>"+Org_Name+"</td><td onmouseover='showIt(\""+id+"\");' onmouseout='hideIt(\""+id+"\");' ><input type='button' onclick='addIt(\""+id+"\","+infos[2]+");' style='width:90px;height:23px;background:#2ea2f9; border-radius:4px; font-size:13px; color:#fff; border:none; cursor:pointer;' value='+新增下级组织' /><input type='button' onclick='moveIt(\""+id+"\");' style='margin:0 10px;width:75px;height:23px;background:#2ea2f9; border-radius:4px; font-size:13px; color:#fff; border:none; cursor:pointer;' value='-删除本组织' /><input type='hidden' value='"+infos[2]+"'/></td></tr>";
    }else{
    var html = "<tr id='"+id+"'><td style='font-size:15px;height:15px;width:220px;padding-top:5px;padding-left:"+distance+"px;' onclick='changeIt(\""+id+"\","+infos[2]+");'>"+Org_Name+"</td><td onmouseover='showIt(\""+id+"\");' onmouseout='hideIt(\""+id+"\");' ><input type='button' onclick='moveIt(\""+id+"\");' style='width:75px;height:23px;background:#2ea2f9; border-radius:4px; font-size:13px; color:#fff; border:none; cursor:pointer;' value='-删除本组织' /><input type='hidden' value='"+infos[2]+"'/></td></tr>";
    }
    $("#orgTable").after(html);
    }
    }
    }
      

  2.   

    $("#orgTable").find("tr").each(function(){
    var sid = $(this).attr("id");
    var val = $("#"+sid+" td").eq(0).text();
    sid = sid.substring(0,sid.lastIndexOf("_"));
    if((""+fid) == (""+sid)){
    flag = false;
    }
    });就是这个这遍历就不好使了。。(单独回复三次就不能回复了。。抱歉)
      

  3.   

    orgTable是表的id。。因为其他地方也有引用这个方法,别的都好使,就这个动态生成的table不能用。。
      

  4.   

    嗯  那个遍历是在moveIt()方法中执行的
      

  5.   

    orgTable是表的id,那 $("#orgTable").after(html);这样就不对了、改成
    $("#orgTable tbody").append(html);
      

  6.   

    $("#orgTable").append(html);需要累加用append
    $("#orgTable").html(html);不需要累加用html