随笔 - 54,  文章 - 0,  评论 - 1,  阅读 - 39578
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=\"width: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>

posted on   北边那座城  阅读(865)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
历史上的今天:
2019-06-17 删除多条商品
2019-06-17 前台验证邮箱不能重复

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示