首页 > 其他 > 详细

修改 input type=file 的样式

时间:2019-10-10 19:03:56      阅读:379      评论:0      收藏:0      [点我收藏+]

页面Html

 <a href="javascript:;" class="file"><span id="filename">选择文件</span>
    <input type="file" name="picture" id="picture">
 </a>

CSS

 .file {
            position: relative;
            background: rgb(244,255,251);
            border: 1px solid #00D6A3;
            border-radius: 4px;
            padding: 4px 12px;
            overflow: hidden;
            color: #00D6A3;
            text-decoration: none;
            text-indent: 0;
            line-height: 20px;
            margin-left: 20px;
            cursor: pointer;
        }
        .file input {
            position: absolute;
            font-size: 100px;
            right: 0;
            top: 0;
            opacity: 0;
            cursor: pointer;
        }
        .file:hover {
            background:  #00D6A3;
            border-color:  #00D6A3;
            color: #ffffff;
            text-decoration: none;
            cursor: pointer;
        }

选中文件获取名字

 $(".file").on("change","input[type=‘file‘]",function(){
            var filePath=$(this).val();
                var arr=filePath.split(‘\\‘);
                var fileName=arr[arr.length-1];
                $("#filename").html(fileName);
    })

  

 

修改 input type=file 的样式

原文:https://www.cnblogs.com/catyxiao/p/11649610.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!