Bootstrap-使用jQuery清除所选文件-数据关闭? [英] Bootstrap - Clear selected file using jquery - data-dismiss?

查看:110
本文介绍了Bootstrap-使用jQuery清除所选文件-数据关闭?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我让这个div致力于成为图片上传者.我有一个div,其中会在选择文件时显示.我也想摆脱<a>,只是使用jQuery清除上传的字段.

So I have this div dedicated to being an image uploader. I have a div within that will show when a file is chosen. I also have <a> that I want to get rid of and just clear out the uploaded field using jQuery.

有人知道吗?我对<a>进行了.bind()'da click事件,但没有成功...(加上我想摆脱所有链接)我认为这是因为有效成分"是data-dismiss="fileupload"部分<a>.

Does anyone know how? I .bind()'d a click event to the <a> but it didn't work... (plus I want to get rid of the link all together) I believe it's because the "active ingredient" is the data-dismiss="fileupload" part of the <a>.

我该如何使用代码而不是锚标签来解雇这个坏男孩?

How can I fire this bad boy using code rather then an anchor tag?

这是我的代码:

<div id="fileuploader" class="fileupload fileupload-new" data-provides="fileupload">
    <div class="fileupload-new thumbnail" style="max-height: 215px; max-width: 175px;">
        <img src="http://www.placehold.it/175x215/EFEFEF/AAAAAA&text=no+image" />
    </div>
    <div class="fileupload-preview fileupload-exists thumbnail" style="max-height: 215px; max-width: 175px; line-height: 20px;">

    </div>
    <div>
        <span class="btn btn-file">
            <span class="fileupload-new">Select image</span>
            <span class="fileupload-exists">Change</span>
            <form>
                <input type="file" name="chosenfile" id="chosenfile"/>
            </form>
        </span>
        <a href="#" id="remove" class="btn fileupload-exists" data-dismiss="fileupload">Remove</a>
    </div>
</div>

推荐答案

我不确定您要做什么,但我认为您想使用这种click函数...

I'm not sure exactly what you're looking to do, but I think you want to use the click function like this...

$('#remove').click(function(){
    $('#chosenfile').val('');
})

这是一个演示

这篇关于Bootstrap-使用jQuery清除所选文件-数据关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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