file控件选择上传文件确定后触发什么js事件

html-css010

file控件选择上传文件确定后触发什么js事件,第1张

1、定义一个Html文件,编写file控件。

2、在html文件中增加js代码,监听File控件。

3、预览页面效果。

4、上面的上传文件比较复杂,可以用jquery更简便的方法。

5、点击选择文件按钮,进行选择文件。

6、编辑完ihtml文件后,用浏览器打开html文件,当鼠标左键单击span时显示"触发鼠标单击事件",双击span时显示"事件",完成关闭。

直接写

CSS样式

是不行的

<input

type="text"

size="20"

name="upfile"

id="upfile"

style="border:1px

dotted

#ccc">

<input

type="button"

value="浏览"

onclick="path.click()"

style="border:1px

solid

#cccbackground:#fff">

<input

type="file"

id="path"

style="display:none"

onchange="upfile.value=this.value">

写成这样,用一个text和一个button替代file,然后让file隐藏