Skip to content

Instantly share code, notes, and snippets.

@dougal
Created January 9, 2010 00:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dougal/272619 to your computer and use it in GitHub Desktop.
Save dougal/272619 to your computer and use it in GitHub Desktop.
<!--
Written for a blog post by Douglas F Shearer
http://douglasfshearer.com/blog/clearing-a-file-input-field-using-jquery
-->
<script type="text/javascript" charset="utf-8" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js">
</script>
<span="myfileinput"><input type="file" name="myfile" /></span>
<a href="" id="clearmyfile">clear</a>
<script type="text/javascript" charset="utf-8">
$('#clearmyfile').click(function(){
var fieldSpan = $('#myfileinput');
fieldSpan.html(fieldSpan.html());
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment