Skip to content

acdvorak/jquery.autosize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jQuery autoSize Plugin

Automatically resizes <input> and <textarea> elements as the user types to fit the entire value.

Respects min/max-width/height and every other CSS property you can imagine because the element's computed CSS properties are copied verbatim to a dummy offscreen <div> for measuring.

Dependencies

  • jQuery
  • Underscore

Browser Support

  • IE 8+
  • Chrome, Safari, Firefox

Usage

Inputs:

$('input').autoWidth();

TextAreas:

$('textarea').autoHeight();

Config

Name Type Default Value Element
numPaddingChars {Number} 1 <input>
numPaddingLines {Number} 0 <textarea>

Example:

$('input').autoWidth({
    numPaddingChars: 2
});

$('textarea').autoHeight({
    numPaddingLines: 1
});

Caveats

  • Breaks undo/redo in IE 8. See jQuery UI bug #7873.

    IE won't allow [you] to perform CTRL + Z (undo) immediately after a DOM append or innerHTML operation.

License

Released under the MIT license.

About

jQuery plugin to automatically resize input and textarea elements

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published