博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
转:[web]javascript 增加表單的input
阅读量:7039 次
发布时间:2019-06-28

本文共 765 字,大约阅读时间需要 2 分钟。

利用javascript增加form的input

這是js的部份

//用來區分不同input的namevar element_count = 0; function add_element(obj){  element_count++;  //先建立一個input的tag  var new_element = document.createElement("input");  //設定這個input的屬性  //可以這樣用  new_element.type = "text";  new_element.name = "new" + element_count;  new_element.value = element_count;  //也可以這樣用  new_element.setAttribute("type","text");  new_element.setAttribute("name","new" + element_count);  new_element.setAttribute("value",element_count);  //最後再使用appendChild加到要加的form裡  obj.form.appendChild(new_element);  //換行用~ 一樣是要加到form裡  var s = document.createElement("br");  obj.form.appendChild(s);}

這是html的部份

posted on
2017-07-23 17:09 阅读(
...) 评论(
...)

转载于:https://www.cnblogs.com/zelos/p/7225334.html

你可能感兴趣的文章
转 MySQL数据库基础
查看>>
ubuntu 解压命令全部
查看>>
Chrome教程(一)NetWork面板分析网络请求
查看>>
第十八回  基础才是重中之重~开发人员应学会用throw
查看>>
Rosenblatt's perceptron
查看>>
1570:基础练习 分解质因数
查看>>
判断ie浏览器7、8、9三个版本
查看>>
GDUFE ACM-1124
查看>>
Schwarz积分公式
查看>>
工作中常用的 Linux 命令
查看>>
English Corner
查看>>
(最短路 SPFA)Invitation Cards -- poj -- 1511
查看>>
两数相加LeetCode
查看>>
列表生成 加1四种方法
查看>>
springboot 处理后端long传给前端精度丢失问题
查看>>
[译文]扩展Repeater控件以支持DataPager分页
查看>>
88. Merge Sorted Array
查看>>
java抽象类和接口区别
查看>>
构建Ruby开发环境(Windows+Eclipse+Aptana Plugin)
查看>>
Miao Xian 隐私政策
查看>>