html代码:
<textarea id="attachTr" style="display:none">
<tr id="attachTr{0}">
<td align="center"><a onclick="removeAttachLine({0});" href="javascript:void(0);" class="pn-opt">删除</a></td>
<td align="center"><div class="search_b"><input type="text" class="search_ip" id="attachmentNames{0}" name="attachmentNames"/></div></td>
<input type="hidden" size="10" id="attachmentPaths{0}" name="attachmentPaths"/>
<td align="center">
<span id="afc{0}"><input type="file" size="10" id="attachmentFile{0}" name="attachmentFile" size="12"/></span>
<input type="button"  class="Cont_ip_q1" onmouseover="this.className='Cont_ip_q2';" onmouseout="this.className='Cont_ip_q1';" value="上传" onclick="uploadAttachment({0});"/>
<input type="hidden" id="attachmentFilenames{0}" name="attachmentFilenames"/>
</td>
</tr>
 </textarea>
js代码:
var attachIndex = 1;
var attachTpl = $.format($("#attachTr").val());
function addAttachLine() {
var trHtml=attachTpl(attachIndex++);
$("#attachTable").append(trHtml);
}
添加的行在后台已经添加了,还取得到值,但是就是IE7下不显示,IE8,IE9都可以,请问各位大虾帮帮忙啊!!!

解决方案 »

  1.   

    你这段html代码怎么看都是错的,不知道怎么还会能显示出来
    没有table直接写tr\td,把tr/td写到textarea中,input放在tr中,汗,怎么来的代码哦,还居然能显示出来?
    你自己建一个html文件把代码放进去试试,不觉得能显示出什么东西
      

  2.   


    table动态添加行其实很容易,简单例子:<html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>无标题页</title>
    </head>
    <script type="text/javascript" src="js/jquery.js"></script>
    <script type="text/javascript">
    function addRows(value)
    {
       var obj=document.getElementById('tab1');
       var arow= obj.insertRow(obj.rows.length);
       var atd=arow.insertCell(0);
      atd.innerHTML=value[0];
       atd=atd=arow.insertCell(1);
       atd.innerHTML=value[1];
    }</script>
    <body>
        <form id="form1" runat="server">
    <table id='tab1'>
     <tr><td>1</td><td>2</td></tr><tr><td>1</td><td>2</td></tr>
    </table> 
    <button type="button" onclick="addRows(['1','2'])">添加行</button>
        </form>
    </body>
    </html>
      

  3.   


    table动态添加行其实很容易,简单例子:<html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>无标题页</title>
    </head>
    <script type="text/javascript" src="js/jquery.js"></script>
    <script type="text/javascript">
    function addRows(value)
    {
       var obj=document.getElementById('tab1');
       var arow= obj.insertRow(obj.rows.length);
       var atd=arow.insertCell(0);
      atd.innerHTML=value[0];
       atd=atd=arow.insertCell(1);
       atd.innerHTML=value[1];
    }</script>
    <body>
        <form id="form1" runat="server">
    <table id='tab1'>
     <tr><td>1</td><td>2</td></tr><tr><td>1</td><td>2</td></tr>
    </table> 
    <button type="button" onclick="addRows(['1','2'])">添加行</button>
        </form>
    </body>
    </html>
      

  4.   

    这是把tr,td放在textarea中,然后用jquery的format方法取出来再赋到一个table里面的
      

  5.   

    以下为改进版,添加“删除”操作<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <script type="text/javascript" src="js/jquery/jquery-1.7.1.js"></script>
    <title>无标题文档</title>
    </head><body>
    <table>
    <tr>
    <td>
    <input type="button" value="添加" id="addtr" style="cursor:pointer;"/>
    <table id="t" border=0 class="ml10"></table>
    </td>
    </tr>
    </table>
    </body>
    <script type="text/javascript">
    $(document).ready(function(){
    function addTr(){
    $('<tr><td>123456</td><td><input type="button" class="del" style="cursor:pointer;" value="删除" /></td></tr>').appendTo($("#t"));
    }
        //删除行
        function BindEvent(){
          $(".del").click(function(){
            $(this).parent().parent().remove();
          });
        }
        //添加行
        $("#addtr").click(function(){
         addTr();
          BindEvent();
        });
    });
    </script>
    </html>