码迷,mamicode.com
首页 > Web开发 > 详细

js动态新增组合Input标签

时间:2015-02-28 18:13:54      阅读:212      评论:0      收藏:0      [点我收藏+]

标签:

 var x = 1;
        function addlink() {
           
            var linkdiv = document.getElementById("add1_0");
            if (linkdiv.attributes.currentindex.value) {
                var tmp = linkdiv.attributes.currentindex.value;
                x = parseInt(tmp) + 1;
            }
            linkdiv.setAttribute(‘currentindex‘, x);
            var proid = ‘proid‘+ x ;
            var price = ‘price‘+ x ;

            $(‘#proid‘ + (x - 1)).after(‘+<input type="text" style="width: 50px;" id=\"‘ + proid + ‘\" />‘);
            $(‘#price‘ + (x - 1)).after(‘+<input type="text" style="width: 50px;" id=\"‘ + price + ‘\" />‘);           
        }

 一个简单的演示

  <p>商品ID:<input type="text" style="width: 50px;" id="proid0" />=<input type="text" id="Mixprice" style="width: 50px;" />
                                            <input type="button" value="增加" onclick="addlink();" /></p>
                                            <p>价   格:<input type="text" style="width: 50px;" id="price0" /></p>

 效果图

技术分享

js动态新增组合Input标签

标签:

原文地址:http://www.cnblogs.com/UnJie/p/4305805.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!