js添加append

 

<div id="display_div"></div>
  <script>
  i=0;
  function add_div(){
  i=i+1;
  //alert(i);
  var div='<div id="div'+i+'"> 服务名称:<input name="detail_title[]" type="text" style="margin-right:5px; height:30px; border:#ccc 1px solid; color:#999; width:270px;" /><br /> 服务说明:<input name="detail_description[]" type="text" style="margin-right:5px; height:30px; border:#ccc 1px solid; color:#999; width:270px;" /><br /> 图  片:<input name="img_url[]" type="file" style="margin-right:5px; height:30px; border:#ccc 1px solid; color:#999; width:270px;" value="上传图片"/> <a href="javascript:" onclick="remove_del('+i+');">删除</a><br> </div>';
  $('#display_div').append(div+'<hr>')
  }
  function remove_del(i){
  //alert(i);
  //alert($("#div"+i));
  $("#div"+i).remove();
  }
  </script>
  </div>
  <a href = "javascript:void(0)onclick="add_div();style="border:0px"><divstyle=" height:115px; border:#ccc dotted; margin-top:7px; line-height:115px; font-size:60px; color:#999999; font-weight:bold; text-align:center"> + </div></a>
    A+
发布日期:2014年02月23日  所属分类:未分类

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: