<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<span>上传图片</span>
<br>
<div><input type="file" id="upfile" sylt='display: none;'>
</div>
</body>
</html>当点击上传图片时显示FIL再点就使这隐藏,最好能写出代吗,谢谢

解决方案 »

  1.   

    <span onclick=document.getElementById("file").style.display=document.getElementById("file").style.display=="none"?"":"none">上传图片</span>PS.样式是style不是sylt
      

  2.   

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <script>
    function a(){
      var a = document.getElementById("upfile");
      a.style.display = (a.style.display==""?"none":"");
    }
    </script>
    </head>
    <body>
    <span onclick="a()" style="cursor:hand">上传图片</span>
    <br>
    <div><input type="file" id="upfile" style='display: none;'>
    </div>
    </body>
    </html>
      

  3.   

    非常感谢各位的回帖,现在又有新问题了,问题基本差不多。<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    </head>
    <body>
    <span>上传图片</span>
    <span>上传文件</span>
    <br>
    <div><input type="file" id="upfile" sylt='display: none;'>
    </div>
    </body>
    </html>当点击上传图片时显示FILE再点就使这隐藏,当点击上传文件时显示FILE再点就使这隐藏,但是当第一次点击上传图片时显示FILE,然后点击上传文件时会隐藏了FILE,这个问题应该怎么解决,最好能写出代吗,谢谢
      

  4.   

    但是当第一次点击上传图片时显示FILE,然后点击上传文件时会隐藏了FILE这个效果你是想要这样还是不想要这样?
      

  5.   

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gbk" />
    <title>无标题文档</title>
    <script>
    function a(obj){
      var a = document.getElementById("upfile");
      a.style.display = (obj.open?"":"none");
      obj.open=!obj.open;
    }
    </script>
    </head>
    <body>
    <span onclick="a(this)" style="cursor:hand" open="true">上传图片</span>
    <br>
    <span onclick="a(this)" style="cursor:hand" open="true">上传文件</span>
    <br>
    <div><input type="file" id="upfile" style='display: none;'>
    </div>
    </body>
    </html>
      

  6.   

    楼上的结果是很接近了,但是当第一次点击上传图片时显示FILE,然后点击上传文件时会隐藏了FILE,我不想要这样的结果,只能通过点击上传图片来隐藏FILE,这样的效果能做出来吗?