emptying the textarea in IE
I'm trying to empty wherever value/text in the textarea, when a file is uploaded from input. It works fine with FF and Chr开发者_C百科ome, but IE doesn't do the thing. Is there anyway to fix this?
Many thanks in advance.$('input[type=file]').change(function(){
$("textarea#txt_id").val('');
});
<textarea name="txt" id="txt_id" rows="8" cols="64"></textarea>
<input type="file" name="file" id="file_id" />
(Source: #955630)
You may need to use .html()
instead of .val()
I would change
$('input[type=file]').change(function(){
$("textarea#txt_id").val('');
});
<textarea name="txt" id="txt_id" rows="8" cols="64"></textarea>
<input type="file" name="file" id="file_id" />
to
$('input[type=file]').change(function(){
$("textarea#txt_id").html("");
});
<textarea name="txt" id="txt_id" rows="8" cols="64"></textarea>
<input type="file" name="file" id="file_id" />
You aren't actually modifying the 'value' attribute like in an input, only the HTML text between the textarea element.
精彩评论