• 动态添加td输入框


    复制代码
    function addRow() { 
            var tab=document.getElementById("tab");
            var n=document.getElementById("x").rowIndex+1;
            var tr=tab.insertRow(n);
            var td=tr.insertCell(0);                                                                                                                                                                                                                                                                     
            tr.innerHTML="<td class="table_body" align="right">日志内容</td><td class="table_none" colspan="3"><input name="syslogcontentcontent" type="text" id="pcuploadjpg" style="64%" onchange="CheckExt(this)"></td><td class="table_none"><img src="${ctx }/img/button/btn_delete_0.png" btn=btn title='删除'  onClick="deleteRow(this)" ></td>";
        }
    复制代码
    function deleteRow(obj) {
            $(obj).parent().parent().remove();
        }

    动态在div中添加input框

    1
    2
    3
    4
    5
    6
    7
    8
    function  hh(){
              $("#zw1").append('<span id="news_' + InputCount+ '"><li style="margin-top:10px;" class="horizontal_onlyRight" ><input type="text" name="zw11" class="text_input100" onkeyup="tihuan(this)"  value=""/></li>'+"<li style='margin-top:10px;  margin-right:7px;' class="horizontal_onlyRight" ><img onmouseover="JavaScript:$(this).attr('src','${ctx }/img/newbtn/delete_1.png');" onmouseout="JavaScript:$(this).attr('src','${ctx }/img/newbtn/delete_0.png');" src='${ctx }/img/newbtn/delete_0.png' btn=btn title='删除' onclick='javascript:deleteRowSpecs1(this,"+InputCount+");'></li><span/>");
              InputCount++;
         }
              function  hh1(){
                  $("#zw2").append('<span id="news_' + InputCount+ '"><li style="margin-top:10px;"  class="horizontal_onlyRight" ><input type="text" name="zw22" onkeyup="tihuan(this)" class="text_input100"  ></li>'+"<li style='margin-top:10px;  margin-right:7px;'  class="horizontal_onlyRight"><img onmouseover="JavaScript:$(this).attr('src','${ctx }/img/newbtn/delete_1.png');" onmouseout="JavaScript:$(this).attr('src','${ctx }/img/newbtn/delete_0.png');" src='${ctx }/img/newbtn/delete_0.png' btn=btn title='删除' onclick='javascript:deleteRowSpecs1(this,"+InputCount+");'></li><span/>");
                  InputCount++;
           }

      

    1
    2
    3
    4
    5
    <div id="zw1" style="margin-bottom : 60px; margin-top:10px;" >
                               <li class="horizontal_onlyRight" style="margin-top:10px;">
                               <input name="zw11" class="text_input100" id="zw11" onkeyup="tihuan(this)" value="">     
                               </li>
                             </div>

    1、innerHTML写入html代码方法,是原生态JS方法:
    <div id="box"></div>
    <script>document.getElementById("box").innerHTML="需要像box内写入的内容"</script>
    2、append()是jQuery中的方法,需要先引用jQuery库代码。
    <div id="box"></div>
    <script>
    $("#box").append("需要像box内写入的内容");
    </script>

  • 相关阅读:
    学生成绩判定系统
    A@2a139a55 结果产生的原因
    为什么子类的构造方法在运行之前,必须调用父类的构造方法?能不能反过来?为什么不能反过来?
    父类与子类之间构造方法的调用关系
    阅读《大道至简》第六章有感
    大数加法 待完善
    BigInteger大数加法源代码及分析
    随机数组求和
    读《大道至简》第五章“失败的过程也是过程 ”有感
    学习进度第15周
  • 原文地址:https://www.cnblogs.com/ios9/p/13722813.html
Copyright © 2020-2023  润新知