js动态新增组合Input标签

 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>

 效果图

posted on 2015-02-28 16:51  UnLike  阅读(1443)  评论(0编辑  收藏  举报

导航