javascript - 如何在 html 表中动态创建带有 div 类的输入元素?
问题描述
我可以在 html 表中动态创建输入元素,但我需要创建由使用input
包围的动态元素div
javascript
像这样,
<td>
<div class="autocomplete">
<input style="height: 30px !important; width:400px;" class="form-control
rightalign" id="productname0">
</div>
</td>
解决方案
你的问题不是很清楚。尝试类似的事情:
var i = document.createElement("INPUT");
i.type="text";
i.setAttribute("style","height: 30px !important; width:400px;");
i.className="form-control rightalign";
i.id="productname0";
Array.prototype.slice.apply( document.getElementsByClassName("autocomplete")).map(function(div, j){
div.appendChild(i.cloneNode(true));
});
推荐阅读
- javascript - 在画布中选择新图像对象时取消选中复选框(Fabricjs)
- node.js - 如何修复“页面上的错误:ReferenceError:找不到变量:需要”-带有 Sinon.js 的 NodeJS
- docker - 如何使用 Docker 或 Docker-compose 一起安装 apache-airflow 和 apache-beam?
- reactjs - 如何在 BigRock 中托管 Laravel-Mix 应用程序?
- amazon-web-services - logstash 是从 s3 下载日志还是在不下载的情况下读取?
- ios - 调整大小时,SwiftUI Image 组件会缩小
- java - 如何在调用 postgresql 函数时获得动态结果集
- batch-file - 如何修复 RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters 1, True 不是每次都更新
- firebase - 使用 Firebase 电子邮件验证的动态/深度链接?
- port - nmap默认扫描的1000个端口是多少?