반응형
HTML
<div class="filebox"> |
<input type="file" id="file"> |
<input class="upload-name"readonly> |
<label for="file">파일 찾아보기</label> |
</div> |
CSS
/*파일박스*/ |
.filebox input[type="file"] { |
position: absolute; |
width: 0; |
height: 0; |
padding: 0; |
overflow: hidden; |
border: 0; |
} |
.filebox label { |
display: inline-block; |
background: #333; |
color: #fff; |
font-size: 16px; |
cursor: pointer; |
height: auto; |
border-radius: 8px; |
font-weight: 400; |
width: 140px; |
height: 40px; |
line-height: 40px; |
text-align: center; |
margin-left: 20px; |
margin-bottom: 0; |
} |
.filebox .upload-name { |
display: inline-block; |
font-size: 18px; |
padding: 10px; |
border: 1px solid #ddd; |
border-radius: 8px; |
width: 300px; |
height: 40px; |
line-height: 40px; |
color: #ccc; |
overflow: hidden; |
} |
JS
<script type="text/javascript"> |
$(document).ready(function() { |
var fileTarget = $('#file'); |
fileTarget.on('change', function() { // 값이 변경되면 |
var cur = $(".filebox input[type='file']").val(); |
$(".upload-name").val(cur); |
}); |
}); |
</script> |
반응형
'퍼블리셔일기' 카테고리의 다른 글
클릭시 (누르면)레이어팝업 or 박스 나오게 하기 (0) | 2021.01.26 |
---|---|
form submit 해도 repage / return 안되게 하기 (0) | 2021.01.26 |
스와이퍼 모바일에서 다른 사진으로 바꾸기 (0) | 2021.01.21 |
3자리 수마다 콤마 생기게 하기 js [ 1,000 ] (0) | 2021.01.20 |
체크박스/라디오버튼 checkbox radio css 로 꾸미기 (0) | 2021.01.20 |