Skip to content

jQuery UI Interactions & Widgets API

jQuery UI APIs — interaction behaviors (draggable, droppable, sortable) and UI widgets (accordion, datepicker, dialog, tabs).

2 classes · 8 methods

Interactions

4 methods

Interaction plugins that add drag-and-drop and reordering behaviors to elements.

$(el).draggable(options?)

Makes the selected elements draggable by mouse. Supports options like handle, axis, containment, and grid.

Parameters

NameTypeDescription
optionsobjectOptional { handle, axis, containment, grid, revert, ... }.

Returns

jQuery

Example

jquery-ui
$('.box').draggable({
  handle: '.drag-handle',
  containment: 'parent',
  grid: [10, 10],
});
$(el).droppable(options?)

Makes elements accept draggable drops; fires activate/over/out/drop/deactivate callbacks.

Parameters

NameTypeDescription
optionsobjectOptional { accept, hoverClass, drop(event, ui), ... }.

Returns

jQuery

Example

jquery-ui
$('.trash').droppable({
  accept: '.item',
  drop: function (event, ui) {
    ui.draggable.remove();
  },
});
$(el).sortable(options?)

Makes a list of children sortable by drag. Supports placeholder, connectWith, and update callback.

Parameters

NameTypeDescription
optionsobjectOptional { items, placeholder, connectWith, update, ... }.

Returns

jQuery

Example

jquery-ui
$('ul.todos').sortable({
  placeholder: 'placeholder',
  update: function () {
    console.log('order changed');
  },
});
instance('option', key, value)

Gets or sets an option on an existing interaction instance after initialization.

Parameters

NameTypeDescription
keystringOption name.
valueanyNew value (omit to get).

Returns

any | jQuery

Example

jquery-ui
$('.box').draggable('option', 'axis', 'x');

Widgets

4 methods

UI widgets built on the jQuery UI widget factory: accordion, datepicker, dialog, and tabs.

$(el).accordion(options?)

Turns nested headings + content panels into a collapsible accordion.

Parameters

NameTypeDescription
optionsobjectOptional { active, collapsible, heightStyle, ... }.

Returns

jQuery

Example

jquery-ui
$('#acc').accordion({
  collapsible: true,
  heightStyle: 'content',
});
$(el).datepicker(options?)

Attaches a popup datepicker to text inputs. Supports dateFormat, minDate, maxDate, onSelect.

Parameters

NameTypeDescription
optionsobjectOptional { dateFormat, minDate, maxDate, onSelect, ... }.

Returns

jQuery

Example

jquery-ui
$('#dob').datepicker({
  dateFormat: 'yy-mm-dd',
  maxDate: 0,
});
$(el).dialog(options?)

Opens the selected element as a floating, draggable, resizable modal dialog.

Parameters

NameTypeDescription
optionsobjectOptional { modal, buttons, width, height, autoOpen, ... }.

Returns

jQuery

Example

jquery-ui
$('#dlg').dialog({
  modal: true,
  buttons: { OK: function () { $(this).dialog('close'); } },
});
$(el).tabs(options?)

Converts a list of links + content panels into a tabbed interface.

Parameters

NameTypeDescription
optionsobjectOptional { active, collapsible, event, ... }.

Returns

jQuery

Example

jquery-ui
$('#tabs').tabs({
  active: 1,
  event: 'mouseover',
});