2016-10-06 2 views
0

enter image description here파일 재설정 방법 버튼

이미지가 첨부되어 있습니다. 이미지 아래의 "X"아이콘을 클릭하면 파일을 제거 할 수 있지만 "파일 선택"의 오른쪽에있는 파일 이름은 여전히 ​​표시됩니다. 아무도 나에게 그것을 어떻게 다시 되돌릴 지 말해 줄 수 없었다.

다음 코드를 사용하여 이미지를 제거하고 있습니다.

$('div').on('click', '.closeDiv', function(e){ 
      var closest = $(this).closest('td'); 
      var id = closest.find('div:first'); 
      $(this).prev().remove(); 
      $(this).remove(); 
      closest.find('span:first').html(''); 
      $('#'+id).val(""); 
     }) 
+0

[용지 jQuery를 사용하여 (http://stackoverflow.com/questions/1043957/clearing-input-type-file을 -using-jquery) –

+0

[JavaScript를 사용하여 HTML 파일 입력을 지우려면 어떻게해야합니까?] (http://stackoverflow.com/questions/1703228/how-can-i-clear-an-html-file-input-with- 자바 스크립트) –

답변

1

이 시도 :

$('#file_id').val(''); 
// It will remove the selected file. Use it inside your function.