繁体   English   中英

如何删除文件上传中的消息

[英]How to remove the message in the file upload

我想在html中添加输入以上传图像,我的问题是在按钮旁边显示了一条消息,我想删除它我该怎么做? 该链接显示了我的问题:

<input type='file'></input>

http://jsfiddle.net/c3sda/2/

我还想将按钮上的文字从浏览更改为其他可能吗?

没有跨浏览器的方法可以做到这一点。 小部件的实现定义部分中包含“未选择文件”文本,我不相信大多数浏览器会提供特定于浏览器的自定义方式。 另一方面,当value属性为空时,您可以简单地使用CSS覆盖文本。

但是,您可以检查下面给出的演示链接。 它可能会帮助您。

Big button (not hidden so you can see what's going on)
<div class="inputWrapper" style="height: 48px; width: 128px;">
    <input class="fileInput" type="file" name="file1"/>
</div><br/>

Big button (file input is hidden)
<div class="inputWrapper" style="height: 56px; width: 128px;">
    <input class="fileInput hidden" type="file" name="file2"/>
</div><br/>

Medium button (this one has text)
<div class="inputWrapper" style="height: 48px; width: 96px;">
    Upload File
    <input class="fileInput hidden" type="file" name="file3"/>
</div><br/>

Smaller button
<div class="inputWrapper" style="height: 24px; width: 24px;">
    <input class="fileInput hidden" type="file" name="file4"/>
</div>

Javascript:

/ 您可以使用一些jQuery通过更改背景颜色/图像,字体大小/粗细/颜色等来模拟按钮按下效果。

$(function() {
    $(".inputWrapper").mousedown(function() {
        var button = $(this);
        button.addClass('clicked');
        setTimeout(function(){
            button.removeClass('clicked');
        },50);
    });
});

CSS:

.inputWrapper {
    overflow: hidden;
    position: relative;
    cursor: pointer;
    /*Using a background color, but you can use a background image to represent a button*/
    background-color: #DDF;
}

.fileInput {
    cursor: pointer;
    height: 100%;
    position:absolute;
    top: 0;
    right: 0;
    /*This makes the button huge so that it can be clicked on*/
    font-size:50px;
}
.hidden {
    /*Opacity settings for all browsers*/
    opacity: 0;
    -moz-opacity: 0;
    filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0)
}


/*Dynamic styles*/
.inputWrapper:hover {
    background-color: #FDD;
}
.inputWrapper.clicked {
    background-color: #A66;
}


body {
    font-family:Helvetica;
}

否则,请检查演示。

演示版

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM