Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery UI API - Spinner Widget

jQuery UI API - Spinner Widget

Category

Widgets

Usage

**Description:** Enhances text input for entering numeric values with up/down buttons and arrow-key handling.

**Version added:** 1.9

The spinner, or number stepper widget, is the perfect control for handling all kinds of numeric input. It lets users type a value directly or spin an existing value with the keyboard, mouse, or wheel. When combined with Globalize, you can even spin to display currencies and dates for different locales.

The spinner uses two buttons to overlay the text input with increments and decrements of the current value. It adds key events so the same increments and decrements can be done with the keyboard. The spinner represents Globalizenumber formatting and parsing.

Keyboard interaction

After clicking a spin button with the mouse, focus stays in the text field.

When the spinner is not read-only (), the user can type a value, which may produce an invalid value (below the minimum, above the maximum, a step mismatch, non-numeric input). When stepping, whether programmatically or via the spin buttons, the value is coerced to a valid value (for details, see stepUp() and stepDown() description.

Theming

The Spinner Widget uses jQuery UI CSS Framework to define the styles for its look and feel. To use the styles specific to the spinner, you can use the following CSS class names:

- `ui-spinner-input`: The element instantiated by the Spinner Widget `` element. - `ui-spinner-button`: The button control used to increment or decrement the spinner value. The up button additionally has a `ui-spinner-up` class, and the down button additionally has a `ui-spinner-down` class.

Depends on

Additional Notes

Example

A plain numeric selector.









  

  旋转器部件(Spinner Widget)演示