Giter Club home page Giter Club logo

jquery-fileinput's Introduction

jQuery Fileinput Plugin

Normally, you can't use CSS to style HTML file inputs. They'll always look fugly. With jQuery Fileinput you can!

By wrapping the file input on a div, adding a replacement element to provide the visuals and then making the original input invisible. Clicks to the replacement element are propagated to the original input on the browsers that support it, otherwise a transparent file input is placed on top of the replacement.

Downloads

Examples

Trivial

...
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script type="text/javascript" src="https://raw.github.com/javanto/jquery-fileinput/3.1.0/dist/jquery.fileinput.min.js"></script>
<script type="text/javascript">
//<![CDATA[
$().ready(function() {
  $("input[type=file]").fileinput();
});
//]]>
</script>
...
<input type="file" name="foo" />

With replacement HTML

...
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script type="text/javascript" src="https://raw.github.com/javanto/jquery-fileinput/3.1.0/dist/jquery.fileinput.min.js"></script>
<script type="text/javascript">
//<![CDATA[
$().ready(function() {
  $("input[type=file]").fileinput("<button>Browse...</button>");
});
//]]>
</script>
...
<input type="file" name="foo" />

With replacement jQuery selector

...
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script type="text/javascript" src="https://raw.github.com/javanto/jquery-fileinput/3.1.0/dist/jquery.fileinput.min.js"></script>
<script type="text/javascript">
//<![CDATA[
$().ready(function() {
  $("input[type=file]").fileinput($("button").remove());
});
//]]>
</script>
...
<input type="file" name="foo" />
<button>Browse...</button>

API

.fileinput([replacement])

  • replacement Plain HTML, or a jQuery selector for the element intended to replace the file input.

Notes

With Opera (and Firefox versions before 4) we can't support the native CSS pseudo classes. Instead we'll provide them equivalent "pseudo pseudo classes" which are actually just normal CSS classes.

  • .hover for :hover
  • .focus for :focus
  • .active for :active

Demo

At jsFiddle.

Requirements

Brower support

Tested on

  • Chrome
  • 24.0.1312.57 m
  • Chromium
  • 24.0.1312.56
  • Firefox
  • 18.0.2
  • Internet Explorer
  • 10.0.9200.16466
  • Opera
  • 12.14
  • Safari
  • 5.1.7 (7534.57.2)

Developing

  1. Fork
  2. Make your modifications
  3. Make sure you have node and npm installed
  4. Install the dependencies required for the build: npm install node-fs dot uglify-js gits
  5. Install jake: npm install jake -g
  6. Compile and minify: jake
  7. Test
  8. Commit and create a pull request
  9. ???
  10. Profit!

jquery-fileinput's People

Contributors

hleinone avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.