如何在文件选择上触发事件 [英] how to fire event on file select

查看:76
本文介绍了如何在文件选择上触发事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表格

<form  onSubmit="return disableForm(this);" action="upload.php" method="post" name="f" id="wizecho" enctype="multipart/form-data">
    <input type="file" name="file" />
    <button onClick="return disableForm(this),ajaxUpload(this.form,'wizecho_upload.php', '&lt;br&gt;Uploading image please wait.....&lt;br&gt;'); return false;">
        Upload Image
    </button>
</form>

上传图片。

在这里,我需要点击按钮上传图片,然后我将使用 onClick 事件。我想删除上传按钮,一旦在输入中选择了文件,我就想触发该事件。我该怎么办?

Here I need to click on the button to upload the image and I've to use onClick event. I want to remove the upload button and as soon as the file is selected at the input, I want to fire the event. How do I do that??

推荐答案

在文件输入上使用更改事件。

Use the change event on the file input.

$("#file").change(function(){
         //submit the form here
 });

这篇关于如何在文件选择上触发事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆