因为下面<body>里面的层是动态生成的而且要虽然属性虽然已经改了但是页面并没有改。哪位大侠帮忙解决解决啊。
在线等!
代码如下
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>childNodes</title>
</head>
<script>
function change(elm){
     elm.parentNode.parentNode.childNodes[0].display="none";
 
 alert(elm.parentNode.parentNode.firstChild.display);
}
</script>
<body><div>
<div  style="display: block;">div1</div>
<div  >div2<input type="button" onclick="change(this);" value="test"/></div>
</div>
</body>
</html>

解决方案 »

  1.   

    elm.parentNode.parentNode.childNodes[0].style.display="none";
      

  2.   

    奇怪啊,为什么在jsp中不行呢
    这是JS
    function showpic(picelm){
      
         var picParent = picelm.parentNode.parentNode;
    picParent.firstChild.firstChild.style.display="true";
    picParent.firstChild.firstChild.src=picelm.value;

    }
    这是HTML代码:
     <div>
                                    <div style="display:none;"><img src="" ></div>
                                    <div style="display:true;"><input type="file"   onpropertychange="showpic(this);" /> </div>
                                    
                                    </div>我想实现的就是先隐藏含有图片的层,等传上来之后显示这个层并显示图片
      

  3.   

    啊又行了,真晕死了,难道是人品问题啊,一在csdn发问它就怕了,嗯~