首页 > 编程知识 正文

js动态添加html代码,js动态添加控件

时间:2023-05-04 19:04:43 阅读:230930 作者:4438

JS动态添加标签

如代码示例,使用jquery,动态的增加标签:

function addDiv(serial) { //最外层父div var div = document.createElement("div"); document.getElementById("form").appendChild(div); var childDiv1 = document.createElement("div"); document.getElementById(div.id).appendChild(childDiv1); var label1 = document.createElement("label"); document.getElementById(childDiv1.id).appendChild(label1); var childDiv1_1 = document.createElement("div"); document.getElementById(childDiv1.id).appendChild(childDiv1_1); var input1 = document.createElement("input"); document.getElementById(childDiv1_1.id).appendChild(input1); }

 

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。