2016-10-06 30 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- javascript) –

答えて

1

これを試してください:

$('#file_id').val(''); 
// It will remove the selected file. Use it inside your function. 
関連する問題