html增加和删除div

<!DOCTYPE HHTML">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Add And Close Div</title>
<script type="text/javascript" src="js/jquery-1.9.1.min.js" ></script>
</head>
<body>
<form action="" method="post" enctype="multipart/form-data">
<label>请选择上传的图片</label>
<a href="#" id="addImg">增加图片</a>
<div class="mdiv" id="mdiv">
<div class="iptdiv" ><input type="file" name="img[]" class="ipt" /><a href="#" name="rmlink">X</a></div>
</div>
<input type="submit" name="submit" value="上传图片" />
</form>
</body>
<script type="text/javascript">
$(document).ready(function(){
//点击切换宽带展示
$("#addImg").on("click",function(){
$("#mdiv").append('<div class="iptdiv" ><input type="file" name="img[]" class="ipt" /><a href="#" name="rmlink">X</a></div>');
bindListener();
});
function bindListener(){
$("a[name=rmlink]").unbind().click(function(){
$(this).parent().remove();
});
}
});
</script>
</html>
上一篇:java学习三 小数默认为double


下一篇:使用ajax.dll时js脚本错误-XXX未定义