Mika Tuupola
Technology guy with passion for advertising.
File Style Plugin for jQuery
22 October 2007
Browsers do not let you style file inputs. File Style plugin fixes this problem. It enables you to use image as browse button. You can also style filename field as normal textfield using css. It is written using JavaScript and jQuery.
This plugin is inspired by work of Shaun Inman.
Want to see how it works? Check the demo page.
How does it work?
Plugin wraps vanilla file input with div. This div has button as background image. Image button is aligned with file inputs browse button. File input is then hidden by setting opacity to zero. Chosen file is shown in normal text input which mimics file input. This text input also inherits file inputs class. Use this class to style the text input.
How to use?
File Style depends on jQuery. Include both in your header:
<script src="jquery.js" type="text/javascript"></script> <script src="jquery.filestyle.js" type="text/javascript"></script>
You will also need button image such as one below.

Then in your code do something like:
$("input[type=file]").filestyle({
image: "choose-file.gif",
imageheight : 22,
imagewidth : 82,
width : 250
});
介绍了一个使用jQuery实现的文件输入样式调整插件,允许开发者通过图片自定义浏览按钮,并利用CSS美化文件名显示区域。

被折叠的 条评论
为什么被折叠?



