File Style Plugin for jQuery

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
 });

Download

Latest source or minified.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值