我有一个这样的控件,<input type = "text" id = "in"/><input type = "file" id = "xxx"/>我需要获得file里面的文件路径显示到文本框里面,怎么样才能取到file里面的文件路径?

解决方案 »

  1.   

    <script type="text/javascript">
    function show(){
    var a=document.getElementById("file").value;
    document.getElementById("text").value=a;
    document.images[0].src=a;
    }
    </script>
    </head><body>
    <input type="text" id="text">
    <input type="file" id="file" onchange="show()">
    <img src="">
    </body>
    这样试试
      

  2.   

    这样肯定能取到,这个我知道。但是我要的效果是在在文本框里面显示路径,就是想要用jq克隆了file控件之后要把file控件的值取到。在IE下面jq克隆元素是不克隆值的。但是呢,我用.value的方法只能取到文件名,而不能取到这个文件路径