<div class="codetitle"> <span><a style="CURSOR: pointer" data="34249" class="copybut" id="copybut34249" onclick="doCopy('code34249')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code34249"> <br><script type="”text/javascript”" src="%E2%80%9Djquery.js%E2%80%9D"></script><br><br><form action="%E2%80%9D%22" method="”post”" enctype="”multipart/form-data”"> <br><label>请选择上传的图片</label><br><a href="%E2%80%9Djavascript:addimg()%E2%80%9D">增加图片</a><br><div class="”mdiv”" id="”mdiv”"> <br><div class="”iptdiv”"> <br><input type="”file”" name="”img[]”" class="”ipt”"><a href="%E2%80%9D#%E2%80%9D" name="%E2%80%9Drmlink%E2%80%9D">X</a><br> </div> <br> </div> <br><input type="”submit”" name="”submit”" value="”上传图片”"><br> </form> <br><script type="”text/javascript”"><BR>$(document).ready(function(){<BR>bindListener();<BR>});<BR>// 用来绑定事件(使用unbind避免重复绑定)<BR>function bindListener(){<BR>$(“a[name=rmlink]“).unbind().click(function(){<BR>$(this).parent().remove();<BR>})<BR>}<BR>function addimg(){<BR>$(“#mdiv”).append(‘<div class=”iptdiv”><input type=”file” name=”img[]” class=”ipt” /><a href=”#” name=”rmlink”> X </script> </div>');<br>// 为新元素节点添加事件侦听器<br>bindListener();<br>}<br><br>