jquery +/-小样式

<script>部分

       var num = 0;
$(document).on('click','#add',function(){
_this = $(this);
div = _this.parent("div");
// 克隆
cl = div.clone();
div.after(cl);
num++;

})
$(document).on('click','#del',function(){
_this = $(this);
div = _this.parent("div");
if(num>0){
div.remove();
num--;
}


})

</script>

<html>部分

<!--图片上传-->
<div class="input-group">
<span id="add">[+]</span>
<div>
<input type="file" name="Files[]" >
</div>
<span id="del">[-]</span>
</div>

</html>

posted on 2017-10-08 16:47  两袖清风9  阅读(125)  评论(0编辑  收藏  举报