自定义上传按钮样式

效果体验:http://runjs.cn/detail/crltmoya

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<style>


#fileInput1 {
cursor:pointer;
opacity:0;
}

div{
    300px;
    height:200px;
    background:blue;
    cursor:pointer;
}


</style>
</head>

<body>
<input type="file" id="fileInput1" name="fileInput1">

<div>点击</div>
<script src="http://code.jquery.com/jquery.js"></script>
<script>
    $('div').on('click', function(e) {
        //alert(1);
        //e.preventDefault();
        $('input[type=file]').trigger('click');
    })
</script>
</body>
</html>
原文地址:https://www.cnblogs.com/wanliyuan/p/4278510.html