我要在top中添加img,可以
var div1=document.getElementById("top");
var img=document.createElement("image");
img.src="./Images/luobinmao.jpg";
div1.appendChild(img);
问题是此处动态添加的img在html中是没有标记的,此时怎么删除?
用removeChild不行!

解决方案 »

  1.   

    如果是html中事先标记的控件就可以用removeChild来删除,动态的怎么删除也就是控制显示?
    顶下!
      

  2.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
        <title>无标题页</title>
        <script type="text/javascript">
        window.onload=function(){
        var div1=document.getElementById("div1");
    var img=document.createElement("image");
    img.setAttribute("id","image1");//设置id为image1
    img.src="../1.jpg";
    div1.appendChild(img);
        
        }
        
        function remove(){
            var div1=document.getElementById("div1");
             var img=document.getElementById("image1");
             div1.removeChild(img);//通过id找到image并删除    }
        </script>
    </head>
    <body>
    <div id="div1">
        <input id="Button1" type="button" value="button" onclick="remove()" />
    </div>
    </body>
    </html>
      

  3.   

    顺便问下那位老兄用过Membership.ValidateUser?
    怎么用?
      

  4.   

    img=null;
    div1.innerHTML = "";
     
    ORimg.style.display = "none";