2012-03-02 4 views
0

HTML : JQuery와에
지우기 업로드 파일 이름

<input type="file" id="flIcon" /> 

:

<div id="uniform-flIcon" class="uploader"> 
<input id="flIcon" class=" " type="file" style="opacity: 0;"> 
<span class="filename" style="-moz-user-select: none;">document-save.png</span> 
<span class="action" style="-moz-user-select: none;">Choose File</span> 
</div> 

나는 그것을 시도 : 페이지를로드 할 때 나는 방화범 볼

$('#btnAddNew').click(function(event) { 
        alert($("#flIcon").attr('file')); 
        $("div#flIcon").replaceWith("<input type='file' id='flIcon'/>"); 

       }); 

이 심판에서. Clearing <input type='file' /> using jQuery하지만 그게 나를 위해 작동하지 않습니다. 거기에 어떤 브라우저 호환성 문제 또는 일부 실종입니다. 고마워요. 이 같은

+0

의 $ ("#의 flIcon")와 잘 작동 replaceWith ('..').; 여기에서 --- http : //jsfiddle.net/XFyuw/3/ – mini

+0

$ ('# btnAddNew'). ((function (event # {alert ($ # "FlIcon")); $ ("div # flIcon"). replaceWith ("");}); – Ohgodwhy

답변

1

시도 : 다음

<input type="file" id="flIcon" /> 
<div id="btnAddNew">Clear</div> 

과 :

$('#btnAddNew').click(function(event) { 
    $("#flIcon").replaceWith("<input type='file' id='flIcon'/>").html(); 
});​ 
0

예 대린의 솔루션은 잘 작동합니다.

또는 당신이 .. jQuery를 사용하여이 작업을 수행하여 명확도 할 수

$('#flIcon').val(''); 
관련 문제