From af15f2c4a192dea02aab9e519defc68c71763ec4 Mon Sep 17 00:00:00 2001
From: yvesf Make the selected elements Accordion widgets. Semantic requirements: The markup of your accordion container needs pairs of headers and content panels: If you use a different element for the header, specify the header-option with an appropriate selector, eg. header: 'a.header'. The content element must be always next to its header. If you have links inside the accordion content and use a-elements as headers, add a class to them and use that as the header, eg. header: 'a.header'. Use activate(Number) to change the active content programmatically. An accordion doesn't allow more than one content panel to be open at the same time, and it takes a lot of effort to do that. If you are looking for a widget that allows more than one content panel to be open, don't use this. Usually it can be written with a few lines of jQuery instead, something like this: Or animated: This event is triggered every time the accordion changes. If the accordion is animated, the event will be triggered upon completion of the animation; otherwise, it is triggered immediately.
+
+ This event is triggered every time the accordion starts to change.
+ Remove the accordion functionality completely. This will return the element back to its pre-init state.
+ Disable the accordion. Enable the accordion. Get or set any accordion option. If no value is specified, will act as a getter. Set multiple accordion options at once by providing an options object. Returns the .ui-accordion element. Activate a content part of the Accordion programmatically. The index can be a zero-indexed number to match the position of the header to close or a Selector matching an element. Pass Recompute heights of the accordion contents when using the fillSpace option and the container height changed. For example, when the container is a resizable, this method should be called by its resize-event. The jQuery UI Accordion plugin uses the jQuery UI CSS Framework to style its look and feel, including colors and background textures. We recommend using the ThemeRoller tool to create and download custom themes that are easy to build and maintain.
+ If a deeper level of customization is needed, there are widget-specific classes referenced within the jquery.ui.accordion.css stylesheet that can be modified. These classes are highlighed in bold below.
+
+
+ Note: This is a sample of markup generated by the accordion plugin, not markup you should use to create a accordion. The only markup needed for that is jQuery UI Accordion
+ Overview
+ <div id="accordion">
+ <h3><a href="#">First header</a></h3>
+ <div>First content</div>
+ <h3><a href="#">Second header</a></h3>
+ <div>Second content</div>
+</div>
+NOTE: If you want multiple sections open at once, don't use an accordion
+jQuery(document).ready(function(){
+ $('.accordion .head').click(function() {
+ $(this).next().toggle();
+ return false;
+ }).next().hide();
+});
+jQuery(document).ready(function(){
+ $('.accordion .head').click(function() {
+ $(this).next().toggle('slow');
+ return false;
+ }).next().hide();
+});
+ Dependencies
+
+
+ Example
+
+
+$("#accordion").accordion();
+
+<!DOCTYPE html>
+<html>
+<head>
+ <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
+ <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
+
+ <script>
+ $(document).ready(function() {
+ $("#accordion").accordion();
+ });
+ </script>
+</head>
+<body style="font-size:62.5%;">
+
+<div id="accordion">
+ <h3><a href="#">Section 1</a></h3>
+ <div>
+ <p>
+ Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer
+ ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit
+ amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut
+ odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.
+ </p>
+ </div>
+ <h3><a href="#">Section 2</a></h3>
+ <div>
+ <p>
+ Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet
+ purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor
+ velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In
+ suscipit faucibus urna.
+ </p>
+ </div>
+ <h3><a href="#">Section 3</a></h3>
+ <div>
+ <p>
+ Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis.
+ Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero
+ ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quis
+ lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui.
+ </p>
+ <ul>
+ <li>List item one</li>
+ <li>List item two</li>
+ <li>List item three</li>
+ </ul>
+ </div>
+ <h3><a href="#">Section 4</a></h3>
+ <div>
+ <p>
+ Cras dictum. Pellentesque habitant morbi tristique senectus et netus
+ et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in
+ faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia
+ mauris vel est.
+ </p>
+ <p>
+ Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus.
+ Class aptent taciti sociosqu ad litora torquent per conubia nostra, per
+ inceptos himenaeos.
+ </p>
+ </div>
+</div>
+
+</body>
+</html>
+
+Options
+
+ Events
+
+
+
+ change
+
+
+ $('.ui-accordion').bind('accordionchange', function(event, ui) {
+ ui.newHeader // jQuery object, activated header
+ ui.oldHeader // jQuery object, previous header
+ ui.newContent // jQuery object, activated content
+ ui.oldContent // jQuery object, previous content
+});
+ Code examples
+
+
+
+ change
event as an init option.
+
+$( ".selector" ).accordion({
+ change: function(event, ui) { ... }
+});
change
event by type: accordionchange
.
+
+$( ".selector" ).bind( "accordionchange", function(event, ui) {
+ ...
+});
changestart
+
+
+ $('.ui-accordion').bind('accordionchangestart', function(event, ui) {
+ ui.newHeader // jQuery object, activated header
+ ui.oldHeader // jQuery object, previous header
+ ui.newContent // jQuery object, activated content
+ ui.oldContent // jQuery object, previous content
+});
+ Code examples
+
+
+
+ changestart
event as an init option.
+
+$( ".selector" ).accordion({
+ changestart: function(event, ui) { ... }
+});
changestart
event by type: accordionchangestart
.
+
+$( ".selector" ).bind( "accordionchangestart", function(event, ui) {
+ ...
+});
Methods
+
+
+
+ destroy
+
+
+ disable
+
+
+ enable
+
+
+ option
+
+
+ option
+
+
+ widget
+
+
+ activate
+
+
+ false
to close all (only possible with collapsible:true
).resize
+
+
+ Theming
+ Sample markup with jQuery UI CSS Framework classes
+ <div class="ui-accordion ui-widget ui-helper-reset">
+ <h3 class="ui-accordion-header ui-helper-reset ui-state-active ui-corner-top">
+ <span class="ui-icon ui-icon-triangle-1-s"/>
+ <a href="#">Section 1</a>
+ </h3>
+ <div class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content-active">
+ Section 1 content
+ </div>
+ <h3 class="ui-accordion-header ui-helper-reset ui-state-default ui-corner-all">
+ <span class="ui-icon ui-icon-triangle-1-e"/>
+ <a href="#">Section 2</a>
+ </h3>
+ <div class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom">
+ Section 2 content
+ </div>
+ <h3 class="ui-accordion-header ui-helper-reset ui-state-default ui-corner-all">
+ <span class="ui-icon ui-icon-triangle-1-e"/>
+ <a href="#">Section 3</a>
+ </h3>
+ <div class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom">
+ Section 3 content
+ </div>
+</div>
+
<div>
+ <h3><a href="#">Section 1</a></h3>
+ <div>
+ Section 1 content
+ </div>
+ <h3><a href="#">Section 2</a></h3>
+ <div>
+ Section 2 content
+ </div>
+ <h3><a href="#">Section 3</a></h3>
+ <div>
+ Section 3 content
+ </div>
+</div>.
+
+
Adds the specified class to each of the set of matched elements with an optional transition between the states.
+$("p").click(function () { + $(this).addClass("selected", 1000); + }); ++
<!DOCTYPE html> +<html> +<head> + <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> + <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> + <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> + <script src="http://ui.jquery.com/latest/ui/effects.core.js"></script> +<style type="text/css"> + p { cursor: pointer; font-size: 1.2em; } + .selected { color:red; } +</style> + <script> + $(document).ready(function() { + $("p").click(function () { + $(this).addClass("selected", 1000); + }); + }); + </script> +</head> +<body style="font-size:62.5%;"> + <p>Click me to add a 'selected' class.</p> +<p>Click me to add a 'selected' class.</p> +<p>Click me to add a 'selected' class.</p> +</body> +</html> ++
The jQuery UI effects core extends the animate function to be able to animate colors as well. It's heavily used by the class transition feature and it's able to color animate the following properties: +
+with one of the following combinations: +
+
+
Autocomplete, when added to an input field, enables users to quickly find and select from a pre-populated list of values as they type, leveraging searching and filtering.
+By giving an Autocomplete field focus or entering something into it, the plugin starts searching for entries that match and displays a list of values to choose from. By entering more characters, the user can filter down the list to better matches.
+This can be used to enter previous selected values, for example you could use Autocomplete for entering tags, to complete an address, you could enter a city name and get the zip code, or maybe enter email addresses from an address book.
+You can pull data in from a local and/or a remote source: Local is good for small data sets (like an address book with 50 entries), remote is necessary for big data sets, like a database with hundreds or millions of entries to select from.
+Autocomplete can be customized to work with various data sources, by just specifying the source option. A data source can be:
+The local data can be a simple Array of Strings, or it contains Objects for each item in the array, with either a label or value property or both. The label property is displayed in the suggestion menu. The value will be inserted into the input element after the user selected something from the menu. If just one property is specified, it will be used for both, eg. if you provide only value-properties, the value will also be used as the label.
+When a String is used, the Autocomplete plugin expects that string to point to a URL resource that will return JSON data. It can be on the same host or on a different one (must provide JSONP). The request parameter "term" gets added to that URL. The data itself can be in the same format as the local data described above.
+The third variation, the callback, provides the most flexibility, and can be used to connect any data source to Autocomplete. The callback gets two arguments:
+The demos all focus on different variations of the source-option - look for the one that matches your use case, and take a look at the code.
+$("input#autocomplete").autocomplete({ + source: ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"] +}); ++
<!DOCTYPE html> +<html> +<head> + <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> + <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> + <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> + + <script> + $(document).ready(function() { + $("input#autocomplete").autocomplete({ + source: ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"] +}); + }); + </script> +</head> +<body style="font-size:62.5%;"> + +<input id="autocomplete" /> + +</body> +</html> ++
Before a request (source-option) is started, after minLength and delay are met. Can be canceled (return false), then no request will be started and no items suggested.
+search
event as an init option.
+$( ".selector" ).autocomplete({
+ search: function(event, ui) { ... }
+});
+search
event by type: autocompletesearch
.
+$( ".selector" ).bind( "autocompletesearch", function(event, ui) {
+ ...
+});
+Triggered when the suggestion menu is opened.
+open
event as an init option.
+$( ".selector" ).autocomplete({
+ open: function(event, ui) { ... }
+});
+open
event by type: autocompleteopen
.
+$( ".selector" ).bind( "autocompleteopen", function(event, ui) {
+ ...
+});
+Before focus is moved to an item (not selecting), ui.item refers to the focused item. The default action of focus is to replace the text field's value with the value of the focused item, though only if the focus event was triggered by a keyboard interaction. Canceling this event prevents the value from being updated, but does not prevent the menu item from being focused.
+focus
event as an init option.
+$( ".selector" ).autocomplete({
+ focus: function(event, ui) { ... }
+});
+focus
event by type: autocompletefocus
.
+$( ".selector" ).bind( "autocompletefocus", function(event, ui) {
+ ...
+});
+Triggered when an item is selected from the menu; ui.item refers to the selected item. The default action of select is to replace the text field's value with the value of the selected item. Canceling this event prevents the value from being updated, but does not prevent the menu from closing.
+select
event as an init option.
+$( ".selector" ).autocomplete({
+ select: function(event, ui) { ... }
+});
+select
event by type: autocompleteselect
.
+$( ".selector" ).bind( "autocompleteselect", function(event, ui) {
+ ...
+});
+When the list is hidden - doesn't have to occur together with a change.
+close
event as an init option.
+$( ".selector" ).autocomplete({
+ close: function(event, ui) { ... }
+});
+close
event by type: autocompleteclose
.
+$( ".selector" ).bind( "autocompleteclose", function(event, ui) {
+ ...
+});
+After an item was selected; ui.item refers to the selected item. Always triggered after the close event.
+change
event as an init option.
+$( ".selector" ).autocomplete({
+ change: function(event, ui) { ... }
+});
+change
event by type: autocompletechange
.
+$( ".selector" ).bind( "autocompletechange", function(event, ui) {
+ ...
+});
+Remove the autocomplete functionality completely. This will return the element back to its pre-init state.
+Disable the autocomplete.
+Enable the autocomplete.
+Get or set any autocomplete option. If no value is specified, will act as a getter.
+Set multiple autocomplete options at once by providing an options object.
+Returns the .ui-autocomplete element.
+Triggers a search event, which, when data is available, then will display the suggestions; can be used by a selectbox-like button to open the suggestions when clicked. If no value argument is specified, the current input's value is used. Can be called with an empty string and minLength: 0 to display all items.
+Close the Autocomplete menu. Useful in combination with the search method, to close the open menu.
+The jQuery UI Autocomplete plugin uses the jQuery UI CSS Framework to style its look and feel, including colors and background textures. We recommend using the ThemeRoller tool to create and download custom themes that are easy to build and maintain. +
+If a deeper level of customization is needed, there are widget-specific classes referenced within the jquery.ui.autocomplete.css stylesheet that can be modified. These classes are highlighed in bold below. +
+ ++ + Note: This is a sample of markup generated by the autocomplete plugin, not markup you should use to create a autocomplete. The only markup needed for that is <input/>. + +
+ +Button enhances standard form elements like button, input of type submit or reset or anchors to themable buttons with appropiate mouseover and active styles.
+In addition to basic push buttons, radio buttons and checkboxes (inputs of type radio and checkbox) can be converted to buttons: Their associated label is styled to appear as the button, while the underlying input is updated on click.
+In order to group radio buttons, Button also provides an additional widget-method, called Buttonset. Its used by selecting a container element (which contains the radio buttons) and calling buttonset(). Buttonset will also provide visual grouping, and therefore should be used whenever you have a group of buttons. It works by selecting all descendents and applying button() to them. You can enable and disable a buttonset, which will enable and disable all contained buttons. Destroying a buttonset also calls the button's destroy method.
+When using an input of type button, submit or reset, support is limited to plain text labels with no icons.
+$("button").button(); ++
<!DOCTYPE html> +<html> +<head> + <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> + <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> + <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> + + <script> + $(document).ready(function() { + $("button").button(); + }); + </script> +</head> +<body style="font-size:62.5%;"> + +<button>Button label</button> + +</body> +</html> ++
$("#radio").buttonset(); ++
<!DOCTYPE html> +<html> +<head> + <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> + <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> + <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> + + <script> + $(document).ready(function() { + $("#radio").buttonset(); + }); + </script> +</head> +<body style="font-size:62.5%;"> + +<div id="radio"> + <input type="radio" id="radio1" name="radio" /><label for="radio1">Choice 1</label> + <input type="radio" id="radio2" name="radio" checked="checked" /><label for="radio2">Choice 2</label> + <input type="radio" id="radio3" name="radio" /><label for="radio3">Choice 3</label> +</div> + +</body> +</html> ++
There are no events for this plugin.
+Remove the button functionality completely. This will return the element back to its pre-init state.
++
Disable the button.
+Enable the button.
+Get or set any button option. If no value is specified, will act as a getter.
+Set multiple button options at once by providing an options object.
+Returns the .ui-button element.
+Refreshes the visual state of the button. Useful for updating button state after the native element's checked or disabled state is changed programatically.
+The jQuery UI Button plugin uses the jQuery UI CSS Framework to style its look and feel, including colors and background textures. We recommend using the ThemeRoller tool to create and download custom themes that are easy to build and maintain. +
+If a deeper level of customization is needed, there are widget-specific classes referenced within the jquery.ui.button.css stylesheet that can be modified. These classes are highlighed in bold below. +
+ ++ + Note: This is a sample of markup generated by the button plugin, not markup you should use to create a button. The only markup needed for that is <button>Button Label</button>. + +
+ +The jQuery UI Datepicker is a highly configurable plugin that adds datepicker functionality to your pages. You can customize the date format and language, restrict the selectable date ranges and add in buttons and other navigation options easily.
+By default, the datepicker calendar opens in a small overlay onFocus and closes automatically onBlur or when a date is selected. For an inline calendar, simply attach the datepicker to a div or span. +
You can use keyboard shortcuts to drive the datepicker: +
+Datepicker provides support for localizing its content to cater for different languages
+ and date formats. Each localization is contained within its own file with the
+ language code appended to the name, e.g. jquery.ui.datepicker-fr.js
for French.
+ The desired localization file should be include after the main datepicker code. They add their settings to the set
+ of available localizations and automatically apply them as defaults for all instances.
The $.datepicker.regional
attribute holds an array of localizations,
+ indexed by language code, with '' referring to the default (English). Each entry is
+ an object with the following attributes: closeText
, prevText
,
+ nextText
, currentText
, monthNames
,
+ monthNamesShort
, dayNames
, dayNamesShort
,
+ dayNamesMin
, weekHeader
, dateFormat
,
+ firstDay
, isRTL
, showMonthAfterYear
,
+ and yearSuffix
.
You can restore the default localizations with:
+$.datepicker.setDefaults($.datepicker.regional['']);
+
And can then override an individual datepicker for a specific locale:
+$(selector).datepicker($.datepicker.regional['fr']);
+
$("#datepicker").datepicker(); ++
<!DOCTYPE html> +<html> +<head> + <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> + <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> + <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> + + <script> + $(document).ready(function() { + $("#datepicker").datepicker(); + }); + </script> +</head> +<body style="font-size:62.5%;"> + +<div type="text" id="datepicker"></div> + +</body> +</html> ++
Can be a function that takes an input field and current datepicker instance and returns an options object to update the datepicker with. It is called just before the datepicker is displayed.
+beforeShow
event as an init option.
+$('.selector').datepicker({
+ beforeShow: function(input, inst) { ... }
+});
+The function takes a date as a parameter and must return an array with [0] equal to true/false indicating whether or not this date is selectable, [1] equal to a CSS class name(s) or '' for the default presentation, and [2] an optional popup tooltip for this date. It is called for each day in the datepicker before it is displayed.
+beforeShowDay
event as an init option.
+$('.selector').datepicker({
+ beforeShowDay: function(date) { ... }
+});
+Allows you to define your own event when the datepicker moves to a new month and/or year. The function receives the selected year, month (1-12), and the datepicker instance as parameters. this
refers to the associated input field.
onChangeMonthYear
event as an init option.
+$('.selector').datepicker({
+ onChangeMonthYear: function(year, month, inst) { ... }
+});
+Allows you to define your own event when the datepicker is closed, whether or not a date is selected. The function receives the selected date as text ('' if none) and the datepicker instance as parameters. this
refers to the associated input field.
onClose
event as an init option.
+$('.selector').datepicker({
+ onClose: function(dateText, inst) { ... }
+});
+Allows you to define your own event when the datepicker is selected. The function receives the selected date as text and the datepicker instance as parameters. this
refers to the associated input field.
onSelect
event as an init option.
+$('.selector').datepicker({
+ onSelect: function(dateText, inst) { ... }
+});
+Remove the datepicker functionality completely. This will return the element back to its pre-init state.
+Disable the datepicker.
+Enable the datepicker.
+Get or set any datepicker option. If no value is specified, will act as a getter.
+Set multiple datepicker options at once by providing an options object.
+Returns the .ui-datepicker element.
+Open a datepicker in a "dialog" box. +
dateText: the initial date for the date picker as either a Date or a string in the current date format. +
onSelect: A callback function when a date is selected. The function receives the date text and date picker instance as parameters. +
settings: The new settings for the date picker. +
pos: The position of the top/left of the dialog as [x, y] or a MouseEvent that contains the coordinates. If not specified the dialog is centered on the screen.
+Determine whether a date picker has been disabled.
+Close a previously opened date picker.
+Call up a previously attached date picker.
+Redraw a date picker, after having made some external modifications.
+Returns the current date for the datepicker or null if no date has been selected.
+Sets the current date for the datepicker. The new date may be a Date object or a string in the current date format (e.g. '01/26/2009'), a number of days from today (e.g. +7) or a string of values and periods ('y' for years, 'm' for months, 'w' for weeks, 'd' for days, e.g. '+1m +7d'), or null to clear the selected date.
+The jQuery UI Datepicker plugin uses the jQuery UI CSS Framework to style its look and feel, including colors and background textures. We recommend using the ThemeRoller tool to create and download custom themes that are easy to build and maintain. +
+If a deeper level of customization is needed, there are widget-specific classes referenced within the jquery.ui.datepicker.css stylesheet that can be modified. These classes are highlighed in bold below. +
+ ++ + Note: This is a sample of markup generated by the datepicker plugin, not markup you should use to create a datepicker. The only markup needed for that is <input type="text" /> or <div></div>. + +
+ +A dialog is a floating window that contains a title bar and a content area. The dialog window can be moved, resized and closed with the 'x' icon by default.
+If the content length exceeds the maximum height, a scrollbar will automatically appear.
+A bottom button bar and semi-transparent modal overlay layer are common options that can be added.
+A call to $(foo).dialog()
will initialize a dialog instance and will auto-open the dialog by default. If you want to reuse a dialog, the easiest way is to disable the "auto-open" option with: $(foo).dialog({ autoOpen: false })
and open it with $(foo).dialog('open')
. To close it, use $(foo).dialog('close')
. A more in-depth explanation with a full demo is available on the Nemikor blog.
$("#dialog").dialog(); ++
<!DOCTYPE html> +<html> +<head> + <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> + <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> + <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> + + <script> + $(document).ready(function() { + $("#dialog").dialog(); + }); + </script> +</head> +<body style="font-size:62.5%;"> + +<div id="dialog" title="Dialog Title">I'm in a dialog</div> + +</body> +</html> ++
This event is triggered when a dialog attempts to close. If the beforeClose event handler (callback function) returns false, the close will be prevented.
+beforeClose
event as an init option.
+$( ".selector" ).dialog({
+ beforeClose: function(event, ui) { ... }
+});
+beforeClose
event by type: dialogbeforeclose
.
+$( ".selector" ).bind( "dialogbeforeclose", function(event, ui) {
+ ...
+});
+This event is triggered when dialog is opened.
+open
event as an init option.
+$( ".selector" ).dialog({
+ open: function(event, ui) { ... }
+});
+open
event by type: dialogopen
.
+$( ".selector" ).bind( "dialogopen", function(event, ui) {
+ ...
+});
+This event is triggered when the dialog gains focus.
+focus
event as an init option.
+$( ".selector" ).dialog({
+ focus: function(event, ui) { ... }
+});
+focus
event by type: dialogfocus
.
+$( ".selector" ).bind( "dialogfocus", function(event, ui) {
+ ...
+});
+This event is triggered at the beginning of the dialog being dragged.
+dragStart
event as an init option.
+$( ".selector" ).dialog({
+ dragStart: function(event, ui) { ... }
+});
+dragStart
event by type: dialogdragstart
.
+$( ".selector" ).bind( "dialogdragstart", function(event, ui) {
+ ...
+});
+This event is triggered when the dialog is dragged.
+drag
event as an init option.
+$( ".selector" ).dialog({
+ drag: function(event, ui) { ... }
+});
+drag
event by type: dialogdrag
.
+$( ".selector" ).bind( "dialogdrag", function(event, ui) {
+ ...
+});
+This event is triggered after the dialog has been dragged.
+dragStop
event as an init option.
+$( ".selector" ).dialog({
+ dragStop: function(event, ui) { ... }
+});
+dragStop
event by type: dialogdragstop
.
+$( ".selector" ).bind( "dialogdragstop", function(event, ui) {
+ ...
+});
+This event is triggered at the beginning of the dialog being resized.
+resizeStart
event as an init option.
+$( ".selector" ).dialog({
+ resizeStart: function(event, ui) { ... }
+});
+resizeStart
event by type: dialogresizestart
.
+$( ".selector" ).bind( "dialogresizestart", function(event, ui) {
+ ...
+});
+This event is triggered when the dialog is resized. demo
+resize
event as an init option.
+$( ".selector" ).dialog({
+ resize: function(event, ui) { ... }
+});
+resize
event by type: dialogresize
.
+$( ".selector" ).bind( "dialogresize", function(event, ui) {
+ ...
+});
+This event is triggered after the dialog has been resized.
+resizeStop
event as an init option.
+$( ".selector" ).dialog({
+ resizeStop: function(event, ui) { ... }
+});
+resizeStop
event by type: dialogresizestop
.
+$( ".selector" ).bind( "dialogresizestop", function(event, ui) {
+ ...
+});
+This event is triggered when the dialog is closed.
+close
event as an init option.
+$( ".selector" ).dialog({
+ close: function(event, ui) { ... }
+});
+close
event by type: dialogclose
.
+$( ".selector" ).bind( "dialogclose", function(event, ui) {
+ ...
+});
+Remove the dialog functionality completely. This will return the element back to its pre-init state.
+Disable the dialog.
+Enable the dialog.
+Get or set any dialog option. If no value is specified, will act as a getter.
+Set multiple dialog options at once by providing an options object.
+Returns the .ui-dialog element.
+Close the dialog.
+Returns true if the dialog is currently open.
+Move the dialog to the top of the dialogs stack.
+Open the dialog.
+The jQuery UI Dialog plugin uses the jQuery UI CSS Framework to style its look and feel, including colors and background textures. We recommend using the ThemeRoller tool to create and download custom themes that are easy to build and maintain. +
+If a deeper level of customization is needed, there are widget-specific classes referenced within the jquery.ui.dialog.css stylesheet that can be modified. These classes are highlighed in bold below. +
+ ++ + Note: This is a sample of markup generated by the dialog plugin, not markup you should use to create a dialog. The only markup needed for that is <div></div>. + +
+ +The jQuery UI Draggable plugin makes selected elements draggable by mouse.
+Draggable elements gets a class of ui-draggable
. During drag the element also gets a class of ui-draggable-dragging
. If you want not just drag, but drag-and-drop, see the jQuery UI Droppable plugin, which provides a drop target for draggables.
All callbacks (start, stop, drag) receive two arguments: The original browser event and a prepared ui object, view below for a documentation of this object (if you name your second argument 'ui'):
+
+
To manipulate the position of a draggable during drag, you can either use a wrapper as the draggable helper and position the wrapped element with absolute positioning, or you can correct internal values like so: $(this).data('draggable').offset.click.top -= x
.
$("#draggable").draggable(); ++
<!DOCTYPE html> +<html> +<head> + <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> + <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> + <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> + <style type="text/css"> + #draggable { width: 100px; height: 70px; background: silver; } + </style> + <script> + $(document).ready(function() { + $("#draggable").draggable(); + }); + </script> +</head> +<body style="font-size:62.5%;"> + +<div id="draggable">Drag me</div> + +</body> +</html> ++
This event is triggered when dragging starts.
+start
event as an init option.
+$( ".selector" ).draggable({
+ start: function(event, ui) { ... }
+});
+start
event by type: dragstart
.
+$( ".selector" ).bind( "dragstart", function(event, ui) {
+ ...
+});
+This event is triggered when the mouse is moved during the dragging.
+drag
event as an init option.
+$( ".selector" ).draggable({
+ drag: function(event, ui) { ... }
+});
+drag
event by type: drag
.
+$( ".selector" ).bind( "drag", function(event, ui) {
+ ...
+});
+This event is triggered when dragging stops.
+stop
event as an init option.
+$( ".selector" ).draggable({
+ stop: function(event, ui) { ... }
+});
+stop
event by type: dragstop
.
+$( ".selector" ).bind( "dragstop", function(event, ui) {
+ ...
+});
+Remove the draggable functionality completely. This will return the element back to its pre-init state.
+Disable the draggable.
+Enable the draggable.
+Get or set any draggable option. If no value is specified, will act as a getter.
+Set multiple draggable options at once by providing an options object.
+Returns the .ui-draggable element.
+The jQuery UI Draggable plugin uses the jQuery UI CSS Framework to style its look and feel, including colors and background textures. We recommend using the ThemeRoller tool to create and download custom themes that are easy to build and maintain. +
+If a deeper level of customization is needed, there are widget-specific classes referenced within the jquery.ui.draggable.css stylesheet that can be modified. These classes are highlighed in bold below. +
+ ++ + Note: This is a sample of markup generated by the draggable plugin, not markup you should use to create a draggable. The only markup needed for that is <div></div>. + +
+ +The jQuery UI Droppable plugin makes selected elements droppable (meaning they accept being dropped on by draggables). You can specify which (individually) or which kind of draggables each will accept.
+All callbacks receive two arguments: The original browser event and a prepared ui object, view below for a documentation of this object (if you name your second argument 'ui'):
+$("#draggable").draggable(); + $("#droppable").droppable({ + drop: function() { alert('dropped'); } + }); ++
<!DOCTYPE html> +<html> +<head> + <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> + <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> + <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> + <style type="text/css"> + #draggable { width: 75px; height: 25px; background: silver; padding: 10px; } + #droppable { position: absolute; left: 250px; top: 0; width: 125px; height: 75px; background: gray; color: white; padding: 10px; } + </style> + <script> + $(document).ready(function() { + $("#draggable").draggable(); + $("#droppable").droppable({ + drop: function() { alert('dropped'); } + }); + }); + </script> +</head> +<body style="font-size:62.5%;"> + +<div id="droppable">Drop here</div> +<div id="draggable">Drag me</div> + +</body> +</html> ++
This event is triggered any time an accepted draggable starts dragging. This can be useful if you want to make the droppable 'light up' when it can be dropped on.
+activate
event as an init option.
+$( ".selector" ).droppable({
+ activate: function(event, ui) { ... }
+});
+activate
event by type: dropactivate
.
+$( ".selector" ).bind( "dropactivate", function(event, ui) {
+ ...
+});
+This event is triggered any time an accepted draggable stops dragging.
+deactivate
event as an init option.
+$( ".selector" ).droppable({
+ deactivate: function(event, ui) { ... }
+});
+deactivate
event by type: dropdeactivate
.
+$( ".selector" ).bind( "dropdeactivate", function(event, ui) {
+ ...
+});
+This event is triggered as an accepted draggable is dragged 'over' (within the tolerance of) this droppable.
+over
event as an init option.
+$( ".selector" ).droppable({
+ over: function(event, ui) { ... }
+});
+over
event by type: dropover
.
+$( ".selector" ).bind( "dropover", function(event, ui) {
+ ...
+});
+This event is triggered when an accepted draggable is dragged out (within the tolerance of) this droppable.
+out
event as an init option.
+$( ".selector" ).droppable({
+ out: function(event, ui) { ... }
+});
+out
event by type: dropout
.
+$( ".selector" ).bind( "dropout", function(event, ui) {
+ ...
+});
+This event is triggered when an accepted draggable is dropped 'over' (within the tolerance of) this droppable. In the callback, $(this) represents the droppable the draggable is dropped on. +ui.draggable represents the draggable.
+drop
event as an init option.
+$( ".selector" ).droppable({
+ drop: function(event, ui) { ... }
+});
+drop
event by type: drop
.
+$( ".selector" ).bind( "drop", function(event, ui) {
+ ...
+});
+Remove the droppable functionality completely. This will return the element back to its pre-init state.
+Disable the droppable.
+Enable the droppable.
+Get or set any droppable option. If no value is specified, will act as a getter.
+Set multiple droppable options at once by providing an options object.
+Returns the .ui-droppable element.
+The jQuery UI Droppable plugin uses the jQuery UI CSS Framework to style its look and feel, including colors and background textures. We recommend using the ThemeRoller tool to create and download custom themes that are easy to build and maintain. +
+If a deeper level of customization is needed, there are widget-specific classes referenced within the jquery.ui.droppable.css stylesheet that can be modified. These classes are highlighed in bold below. +
+ ++ + Note: This is a sample of markup generated by the droppable plugin, not markup you should use to create a droppable. The only markup needed for that is <div></div>. + +
+ +Uses a specific effect on an element (without the show/hide logic).
+$("p").click(function () { + $("div").effect("explode"); + }); ++
<!DOCTYPE html> +<html> +<head> + <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> + <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> + <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> + <script src="http://ui.jquery.com/latest/ui/effects.core.js"></script> +<script src="http://ui.jquery.com/latest/ui/effects.explode.js"></script> +<style type="text/css"> + div { margin: 0 auto; width: 100px; height: 80px; background: blue; position: relative; } +</style> + <script> + $(document).ready(function() { + $("p").click(function () { + $("div").effect("explode"); + }); + }); + </script> +</head> +<body style="font-size:62.5%;"> + +<p>Click me</p><div></div> + +</body> +</html> ++
The enhanced hide method optionally accepts jQuery UI advanced effects.
+Uses a specific effect on an element to hide the element if the first argument is an effect string.
+$("p").click(function () { + $("div").hide("slide", {}, 1000); + }); ++
<!DOCTYPE html> +<html> +<head> + <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> + <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> + <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> + <script src="http://ui.jquery.com/latest/ui/effects.core.js"></script> +<script src="http://ui.jquery.com/latest/ui/effects.slide.js"></script> +<style type="text/css"> + div { margin: 0px; width: 100px; height: 80px; background: blue; position: relative; } +</style> + <script> + $(document).ready(function() { + $("p").click(function () { + $("div").hide("slide", {}, 1000); + }); + }); + </script> +</head> +<body style="font-size:62.5%;"> + +<p>Click me</p><div></div> + +</body> +</html> ++
Utility script for positioning any widget relative to the window, document, a particular element, or the cursor/mouse.
+Note: jQuery UI does not support positioning hidden elements.
+Does not need ui.core.js or effects.core.js.
++$("#position1").position({ + my: "center", + at: "center", + of: "#targetElement" +}); +$("#position2").position({ + my: "left top", + at: "left top", + of: "#targetElement" +}); +$("#position3").position({ + my: "right center", + at: "right bottom", + of: "#targetElement" +}); +$(document).mousemove(function(ev){ + $("#position4").position({ + my: "left bottom", + of: ev, + offset: "3 -3", + collision: "fit" + }); +}); + ++
<!DOCTYPE html> +<html> +<head> + <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> + <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> + <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> + <style type="text/css"> +#targetElement { width:240px;height:200px;background-color:#999;margin:30px auto; } +.positionDiv { width:50px;height:50px;opacity:0.6; } +#position1 {background-color:#F00;} +#position2 {background-color:#0F0;} +#position3 {background-color:#00F;} +#position4 {background-color:#FF0;} +</style> + + <script> + $(document).ready(function() { + +$("#position1").position({ + my: "center", + at: "center", + of: "#targetElement" +}); +$("#position2").position({ + my: "left top", + at: "left top", + of: "#targetElement" +}); +$("#position3").position({ + my: "right center", + at: "right bottom", + of: "#targetElement" +}); +$(document).mousemove(function(ev){ + $("#position4").position({ + my: "left bottom", + of: ev, + offset: "3 -3", + collision: "fit" + }); +}); + + }); + </script> +</head> +<body style="font-size:62.5%;"> + +<div id="targetElement"> + <div class="positionDiv" id="position1"></div> + <div class="positionDiv" id="position2"></div> + <div class="positionDiv" id="position3"></div> + <div class="positionDiv" id="position4"></div> +</div> + +</body> +</html> ++
+The progress bar is designed to simply display the current % complete for a process. The bar is coded to be flexibly sized through CSS and will scale to fit inside it's parent container by default. +
++This is a determinate progress bar, meaning that it should only be used in situations where the system can accurately update the current status complete. A determinate progress bar should never fill from left to right, then loop back to empty for a single process -- if the actual percent complete status cannot be calculated, an indeterminate progress bar (coming soon) or spinner animation is a better way to provide user feedback. +
+$("#progressbar").progressbar({ value: 37 }); ++
<!DOCTYPE html> +<html> +<head> + <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> + <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> + <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> + + <script> + $(document).ready(function() { + $("#progressbar").progressbar({ value: 37 }); + }); + </script> +</head> +<body style="font-size:62.5%;"> + +<div id="progressbar"></div> + +</body> +</html> ++
This event is triggered when the value of the progressbar changes.
+change
event as an init option.
+$( ".selector" ).progressbar({
+ change: function(event, ui) { ... }
+});
+change
event by type: progressbarchange
.
+$( ".selector" ).bind( "progressbarchange", function(event, ui) {
+ ...
+});
+This event is triggered when the value of the progressbar reaches the maximum value of 100.
+complete
event as an init option.
+$( ".selector" ).progressbar({
+ complete: function(event, ui) { ... }
+});
+complete
event by type: progressbarcomplete
.
+$( ".selector" ).bind( "progressbarcomplete", function(event, ui) {
+ ...
+});
+Remove the progressbar functionality completely. This will return the element back to its pre-init state.
+Disable the progressbar.
+Enable the progressbar.
+Get or set any progressbar option. If no value is specified, will act as a getter.
+Set multiple progressbar options at once by providing an options object.
+Returns the .ui-progressbar element.
+This method gets or sets the current value of the progressbar.
+The jQuery UI Progressbar plugin uses the jQuery UI CSS Framework to style its look and feel, including colors and background textures. We recommend using the ThemeRoller tool to create and download custom themes that are easy to build and maintain. +
+If a deeper level of customization is needed, there are widget-specific classes referenced within the jquery.ui.progressbar.css stylesheet that can be modified. These classes are highlighed in bold below. +
+ ++ + Note: This is a sample of markup generated by the progressbar plugin, not markup you should use to create a progressbar. The only markup needed for that is <div></div>. + +
+ +Removes all or specified class from each of the set of matched elements with an optional transition between the states.
+$("p").click(function () { + $(this).removeClass("selected", 1000); + }); ++
<!DOCTYPE html> +<html> +<head> + <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> + <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> + <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> + <script src="http://ui.jquery.com/latest/ui/effects.core.js"></script> +<style type="text/css"> + p { cursor: pointer; font-size: 1.2em; } + .selected { color:red; } +</style> + <script> + $(document).ready(function() { + $("p").click(function () { + $(this).removeClass("selected", 1000); + }); + }); + </script> +</head> +<body style="font-size:62.5%;"> + +<p class="selected">Click me to remove 'selected' class.</p> +<p class="selected">Click me to remove 'selected' class.</p> +<p class="selected">Click me to remove 'selected' class.</p> + +</body> +</html> ++
The jQuery UI Resizable plugin makes selected elements resizable (meaning they have draggable resize handles). You can specify one or more handles as well as min and max width and height.
+All callbacks (start,stop,resize) receive two arguments: The original browser event and a prepared ui object. The ui object has the following fields:
+$("#resizable").resizable(); ++
<!DOCTYPE html> +<html> +<head> + <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> + <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> + <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> + <style type="text/css"> + #resizable { width: 100px; height: 100px; background: silver; } + </style> + <script> + $(document).ready(function() { + $("#resizable").resizable(); + }); + </script> +</head> +<body style="font-size:62.5%;"> + +<div id="resizable"></div> + +</body> +</html> ++
This event is triggered at the start of a resize operation.
+start
event as an init option.
+$( ".selector" ).resizable({
+ start: function(event, ui) { ... }
+});
+start
event by type: resizestart
.
+$( ".selector" ).bind( "resizestart", function(event, ui) {
+ ...
+});
+This event is triggered during the resize, on the drag of the resize handler.
+resize
event as an init option.
+$( ".selector" ).resizable({
+ resize: function(event, ui) { ... }
+});
+resize
event by type: resize
.
+$( ".selector" ).bind( "resize", function(event, ui) {
+ ...
+});
+This event is triggered at the end of a resize operation.
+stop
event as an init option.
+$( ".selector" ).resizable({
+ stop: function(event, ui) { ... }
+});
+stop
event by type: resizestop
.
+$( ".selector" ).bind( "resizestop", function(event, ui) {
+ ...
+});
+Remove the resizable functionality completely. This will return the element back to its pre-init state.
+Disable the resizable.
+Enable the resizable.
+Get or set any resizable option. If no value is specified, will act as a getter.
+Set multiple resizable options at once by providing an options object.
+Returns the .ui-resizable element.
+The jQuery UI Resizable plugin uses the jQuery UI CSS Framework to style its look and feel, including colors and background textures. We recommend using the ThemeRoller tool to create and download custom themes that are easy to build and maintain. +
+If a deeper level of customization is needed, there are widget-specific classes referenced within the jquery.ui.resizable.css stylesheet that can be modified. These classes are highlighed in bold below. +
+ ++ + Note: This is a sample of markup generated by the resizable plugin, not markup you should use to create a resizable. The only markup needed for that is <div></div>. + +
+ +The jQuery UI Selectable plugin allows for elements to be selected by dragging a box (sometimes called a lasso) with the mouse over the elements. Also, elements can be selected by click or drag while holding the Ctrl/Meta key, allowing for multiple (non-contiguous) selections.
+$("#selectable").selectable(); ++
<!DOCTYPE html> +<html> +<head> + <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> + <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> + <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> + <style type="text/css"> +#selectable .ui-selecting { + background: silver; +} +#selectable .ui-selected { + background: gray; +} +</style> + + <script> + $(document).ready(function() { + $("#selectable").selectable(); + }); + </script> +</head> +<body style="font-size:62.5%;"> + +<ul id="selectable"> +<li>Item 1</li> +<li>Item 2</li> +<li>Item 3</li> +<li>Item 4</li> +<li>Item 5</li> +</ul> + +</body> +</html> ++
This event is triggered at the end of the select operation, on each element added to the selection.
+selected
event as an init option.
+$( ".selector" ).selectable({
+ selected: function(event, ui) { ... }
+});
+selected
event by type: selectableselected
.
+$( ".selector" ).bind( "selectableselected", function(event, ui) {
+ ...
+});
+This event is triggered during the select operation, on each element added to the selection.
+selecting
event as an init option.
+$( ".selector" ).selectable({
+ selecting: function(event, ui) { ... }
+});
+selecting
event by type: selectableselecting
.
+$( ".selector" ).bind( "selectableselecting", function(event, ui) {
+ ...
+});
+This event is triggered at the beginning of the select operation.
+start
event as an init option.
+$( ".selector" ).selectable({
+ start: function(event, ui) { ... }
+});
+start
event by type: selectablestart
.
+$( ".selector" ).bind( "selectablestart", function(event, ui) {
+ ...
+});
+This event is triggered at the end of the select operation.
+stop
event as an init option.
+$( ".selector" ).selectable({
+ stop: function(event, ui) { ... }
+});
+stop
event by type: selectablestop
.
+$( ".selector" ).bind( "selectablestop", function(event, ui) {
+ ...
+});
+This event is triggered at the end of the select operation, on each element removed from the selection.
+unselected
event as an init option.
+$( ".selector" ).selectable({
+ unselected: function(event, ui) { ... }
+});
+unselected
event by type: selectableunselected
.
+$( ".selector" ).bind( "selectableunselected", function(event, ui) {
+ ...
+});
+This event is triggered during the select operation, on each element removed from the selection.
+unselecting
event as an init option.
+$( ".selector" ).selectable({
+ unselecting: function(event, ui) { ... }
+});
+unselecting
event by type: selectableunselecting
.
+$( ".selector" ).bind( "selectableunselecting", function(event, ui) {
+ ...
+});
+Remove the selectable functionality completely. This will return the element back to its pre-init state.
+Disable the selectable.
+Enable the selectable.
+Get or set any selectable option. If no value is specified, will act as a getter.
+Set multiple selectable options at once by providing an options object.
+Returns the .ui-selectable element.
+Refresh the position and size of each selectee element. This method can be used to manually recalculate the position and size of each selectee element. Very useful if autoRefresh is set to false.
+The jQuery UI Selectable plugin uses the jQuery UI CSS Framework to style its look and feel, including colors and background textures. We recommend using the ThemeRoller tool to create and download custom themes that are easy to build and maintain. +
+If a deeper level of customization is needed, there are widget-specific classes referenced within the jquery.ui.selectable.css stylesheet that can be modified. These classes are highlighed in bold below. +
+ +
+
+ Note: This is a sample of markup generated by the selectable plugin, not markup you should use to create a selectable. The only markup needed for that is
<ul>
+ <li></li>
+ <li></li>
+ <li></li>
+</ul>.
+
+
The enhanced show method optionally accepts jQuery UI advanced effects.
+Uses a specific effect on an element to show the element if the first argument is a effect string.
+$("p").click(function () { + $("div").show("slide", {}, 1000); + }); ++
<!DOCTYPE html> +<html> +<head> + <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> + <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> + <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> + <script src="http://ui.jquery.com/latest/ui/effects.core.js"></script> +<script src="http://ui.jquery.com/latest/ui/effects.slide.js"></script> +<style type="text/css"> + div { display: none; margin: 0px; width: 100px; height: 80px; background: blue; position: relative; } +</style> + <script> + $(document).ready(function() { + $("p").click(function () { + $("div").show("slide", {}, 1000); + }); + }); + </script> +</head> +<body style="font-size:62.5%;"> + +<p>Click me</p><div></div> + +</body> +</html> ++
The jQuery UI Slider plugin makes selected elements into sliders. There are various options such as multiple handles, and ranges. The handle can be moved with the mouse or the arrow keys.
+All callbacks receive two arguments: The original browser event and a prepared ui object, view below for a documentation of this object (if you name your second argument 'ui'): +
The slider widget will create handle elements with the class 'ui-slider-handle' on initialization. You can specify custom handle elements by creating and appending the elements and adding the 'ui-slider-handle' class before init. It will only create the number of handles needed to match the length of value/values. For example, if you specify 'values: [1, 5, 18]' and create one custom handle, the plugin will create the other two. +
+$("#slider").slider(); ++
<!DOCTYPE html> +<html> +<head> + <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> + <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> + <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> + <style type="text/css"> + #slider { margin: 10px; } + </style> + <script> + $(document).ready(function() { + $("#slider").slider(); + }); + </script> +</head> +<body style="font-size:62.5%;"> + +<div id="slider"></div> + +</body> +</html> ++
This event is triggered when the user starts sliding.
+start
event as an init option.
+$( ".selector" ).slider({
+ start: function(event, ui) { ... }
+});
+start
event by type: slidestart
.
+$( ".selector" ).bind( "slidestart", function(event, ui) {
+ ...
+});
+This event is triggered on every mouse move during slide. Use ui.value (single-handled sliders) to obtain the value of the current handle, $(..).slider('value', index) to get another handles' value. +
Return false in order to prevent a slide, based on ui.value.
+slide
event as an init option.
+$( ".selector" ).slider({
+ slide: function(event, ui) { ... }
+});
+slide
event by type: slide
.
+$( ".selector" ).bind( "slide", function(event, ui) {
+ ...
+});
+This event is triggered on slide stop, or if the value is changed programmatically (by the value
method). Takes arguments event and ui. Use event.orginalEvent to detect whether the value changed by mouse, keyboard, or programmatically. Use ui.value (single-handled sliders) to obtain the value of the current handle, $(this).slider('values', index) to get another handle's value.
change
event as an init option.
+$( ".selector" ).slider({
+ change: function(event, ui) { ... }
+});
+change
event by type: slidechange
.
+$( ".selector" ).bind( "slidechange", function(event, ui) {
+ ...
+});
+This event is triggered when the user stops sliding.
+stop
event as an init option.
+$( ".selector" ).slider({
+ stop: function(event, ui) { ... }
+});
+stop
event by type: slidestop
.
+$( ".selector" ).bind( "slidestop", function(event, ui) {
+ ...
+});
+Remove the slider functionality completely. This will return the element back to its pre-init state.
+Disable the slider.
+Enable the slider.
+Get or set any slider option. If no value is specified, will act as a getter.
+Set multiple slider options at once by providing an options object.
+Returns the .ui-slider element.
+Gets or sets the value of the slider. For single handle sliders.
+Gets or sets the values of the slider. For multiple handle or range sliders.
+The jQuery UI Slider plugin uses the jQuery UI CSS Framework to style its look and feel, including colors and background textures. We recommend using the ThemeRoller tool to create and download custom themes that are easy to build and maintain. +
+If a deeper level of customization is needed, there are widget-specific classes referenced within the jquery.ui.slider.css stylesheet that can be modified. These classes are highlighed in bold below. +
+ ++ + Note: This is a sample of markup generated by the slider plugin, not markup you should use to create a slider. The only markup needed for that is <div><div>. + +
+ +The jQuery UI Sortable plugin makes selected elements sortable by dragging with the mouse.
+All callbacks receive two arguments: The original browser event and a prepared ui object, view below for a documentation of this object (if you name your second argument 'ui'):
+$("#sortable").sortable(); ++
<!DOCTYPE html> +<html> +<head> + <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> + <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> + <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> + + <script> + $(document).ready(function() { + $("#sortable").sortable(); + }); + </script> +</head> +<body style="font-size:62.5%;"> + +<ul id="sortable"> +<li>Item 1</li> +<li>Item 2</li> +<li>Item 3</li> +<li>Item 4</li> +<li>Item 5</li> +</ul> + +</body> +</html> ++
This event is triggered when sorting starts.
+start
event as an init option.
+$( ".selector" ).sortable({
+ start: function(event, ui) { ... }
+});
+start
event by type: sortstart
.
+$( ".selector" ).bind( "sortstart", function(event, ui) {
+ ...
+});
+This event is triggered during sorting.
+sort
event as an init option.
+$( ".selector" ).sortable({
+ sort: function(event, ui) { ... }
+});
+sort
event by type: sort
.
+$( ".selector" ).bind( "sort", function(event, ui) {
+ ...
+});
+This event is triggered during sorting, but only when the DOM position has changed.
+change
event as an init option.
+$( ".selector" ).sortable({
+ change: function(event, ui) { ... }
+});
+change
event by type: sortchange
.
+$( ".selector" ).bind( "sortchange", function(event, ui) {
+ ...
+});
+This event is triggered when sorting stops, but when the placeholder/helper is still available.
+beforeStop
event as an init option.
+$( ".selector" ).sortable({
+ beforeStop: function(event, ui) { ... }
+});
+beforeStop
event by type: sortbeforestop
.
+$( ".selector" ).bind( "sortbeforestop", function(event, ui) {
+ ...
+});
+This event is triggered when sorting has stopped.
+stop
event as an init option.
+$( ".selector" ).sortable({
+ stop: function(event, ui) { ... }
+});
+stop
event by type: sortstop
.
+$( ".selector" ).bind( "sortstop", function(event, ui) {
+ ...
+});
+This event is triggered when the user stopped sorting and the DOM position has changed.
+update
event as an init option.
+$( ".selector" ).sortable({
+ update: function(event, ui) { ... }
+});
+update
event by type: sortupdate
.
+$( ".selector" ).bind( "sortupdate", function(event, ui) {
+ ...
+});
+This event is triggered when a connected sortable list has received an item from another list.
+receive
event as an init option.
+$( ".selector" ).sortable({
+ receive: function(event, ui) { ... }
+});
+receive
event by type: sortreceive
.
+$( ".selector" ).bind( "sortreceive", function(event, ui) {
+ ...
+});
+This event is triggered when a sortable item has been dragged out from the list and into another.
+remove
event as an init option.
+$( ".selector" ).sortable({
+ remove: function(event, ui) { ... }
+});
+remove
event by type: sortremove
.
+$( ".selector" ).bind( "sortremove", function(event, ui) {
+ ...
+});
+This event is triggered when a sortable item is moved into a connected list.
+over
event as an init option.
+$( ".selector" ).sortable({
+ over: function(event, ui) { ... }
+});
+over
event by type: sortover
.
+$( ".selector" ).bind( "sortover", function(event, ui) {
+ ...
+});
+This event is triggered when a sortable item is moved away from a connected list.
+out
event as an init option.
+$( ".selector" ).sortable({
+ out: function(event, ui) { ... }
+});
+out
event by type: sortout
.
+$( ".selector" ).bind( "sortout", function(event, ui) {
+ ...
+});
+This event is triggered when using connected lists, every connected list on drag start receives it.
+activate
event as an init option.
+$( ".selector" ).sortable({
+ activate: function(event, ui) { ... }
+});
+activate
event by type: sortactivate
.
+$( ".selector" ).bind( "sortactivate", function(event, ui) {
+ ...
+});
+This event is triggered when sorting was stopped, is propagated to all possible connected lists.
+deactivate
event as an init option.
+$( ".selector" ).sortable({
+ deactivate: function(event, ui) { ... }
+});
+deactivate
event by type: sortdeactivate
.
+$( ".selector" ).bind( "sortdeactivate", function(event, ui) {
+ ...
+});
+Remove the sortable functionality completely. This will return the element back to its pre-init state.
+Disable the sortable.
+Enable the sortable.
+Get or set any sortable option. If no value is specified, will act as a getter.
+Set multiple sortable options at once by providing an options object.
+Returns the .ui-sortable element.
+Serializes the sortable's item id's into a form/ajax submittable string. Calling this method produces a hash that can be appended to any url to easily submit a new item order back to the server. +
It works by default by looking at the id of each item in the format 'setname_number', and it spits out a hash like "setname[]=number&setname[]=number". +
You can also give in a option hash as second argument to custom define how the function works. The possible options are: 'key' (replaces part1[] with whatever you want), 'attribute' (test another attribute than 'id') and 'expression' (use your own regexp). +
If serialize returns an empty string, make sure the id attributes include an underscore. They must be in the form: "set_number" For example, a 3 element list with id attributes foo_1, foo_5, foo_2 will serialize to foo[]=1&foo[]=5&foo[]=2. You can use an underscore, equal sign or hyphen to separate the set and number. For example foo=1 or foo-1 or foo_1 all serialize to foo[]=1.
+Serializes the sortable's item id's into an array of string. If you have +
++<ul id="a_sortable"><br> +<li id="hello">Hello</li><br> +<li id="goodbye">Good bye</li><br> +</ul> ++
and do +
+var result = $('#a_sortable').sortable('toArray');+
then +
+result[0] will contain "hello" and result[1] will contain "goodbye".+
+
Refresh the sortable items. Custom trigger the reloading of all sortable items, causing new items to be recognized.
+Refresh the cached positions of the sortables' items. Calling this method refreshes the cached item positions of all sortables. This is usually done automatically by the script and slows down performance. Use wisely.
+Cancels a change in the current sortable and reverts it back to how it was before the current sort started. Useful in the stop and receive callback functions. +
If the sortable item is not being moved from one connected sortable to another: +
+$(this).sortable('cancel');+
will cancel the change. +
If the sortable item is being moved from one connected sortable to another: +
+$(ui.sender).sortable('cancel');+
will cancel the change. Useful in the 'receive' callback.
+The jQuery UI Sortable plugin uses the jQuery UI CSS Framework to style its look and feel, including colors and background textures. We recommend using the ThemeRoller tool to create and download custom themes that are easy to build and maintain. +
+If a deeper level of customization is needed, there are widget-specific classes referenced within the jquery.ui.sortable.css stylesheet that can be modified. These classes are highlighed in bold below. +
+ +
+
+ Note: This is a sample of markup generated by the sortable plugin, not markup you should use to create a sortable. The only markup needed for that is
<ul>
+ <li></li>
+ <li></li>
+ <li></li>
+</ul>.
+
+
Switches from the class defined in the first argument to the class defined as second argument, using an optional transition.
+$("p").click(function () { + $(this).switchClass("highlight", "blue", 1000); + }); ++
<!DOCTYPE html> +<html> +<head> + <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> + <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> + <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> + <script src="http://ui.jquery.com/latest/ui/effects.core.js"></script> +<style type="text/css"> + p { margin: 4px; font-size:16px; font-weight:bolder; + cursor:pointer; } + .blue { background: blue; } + .highlight { background:yellow; } +</style> + <script> + $(document).ready(function() { + $("p").click(function () { + $(this).switchClass("highlight", "blue", 1000); + }); + }); + </script> +</head> +<body style="font-size:62.5%;"> + +<p class="highlight">Click to switch</p> +<p class="highlight">to blue</p> +<p class="highlight">on these</p> +<p class="highlight">paragraphs</p> + +</body> +</html> ++
Tabs are generally used to break content into multiple sections that can be swapped to save space, much like an accordion.
+By default a tab widget will swap between tabbed sections onClick, but the events can be changed to onHover through an option. Tab content can be loaded via Ajax by setting an href on a tab.
+NOTE: Tabs created dynamically using .tabs( "add", ... ) are given an id of ui-tabs-NUM, where NUM is an auto-incrementing id. If you use this naming convention for your own elements, you may encounter problems.
+A series of events fire when interacting with a tabs interface: +
+Event binding example: +
+$('#example').bind('tabsselect', function(event, ui) { + + // Objects available in the function context: + ui.tab // anchor element of the selected (clicked) tab + ui.panel // element, that contains the selected/clicked tab contents + ui.index // zero-based index of the selected (clicked) tab + +});+
Note that if a handler for the tabsselect event returns false, the clicked tab will not become selected (useful for example if switching to the next tab requires a form validation). +
+Tabs supports loading tab content via Ajax in an unobtrusive manner. +
The HTML you need is slightly different from the one that is used for static tabs: A list of links pointing to existing resources (from where the content gets loaded) and no additional containers at all (unobtrusive!). The containers' markup is going to be created on the fly: +
++<div id="example"> + <ul> + <li><a href="ahah_1.html"><span>Content 1</span></a></li> + <li><a href="ahah_2.html"><span>Content 2</span></a></li> + <li><a href="ahah_3.html"><span>Content 3</span></a></li> + </ul> +</div> ++
Obviously this degrades gracefully - the links, e.g. the content, will still be accessible with JavaScript disabled. +
Note that if you wish to reuse an existing container, you +could do so by matching a title attribute and the container's id: +
++<li><a href="hello/world.html" title="Todo Overview"> ... </a></li> ++
and a container like: +
++<div id="Todo_Overview"> ... </div> ++
(Note how white space is replaced with an underscore) +
This is useful if you want a human readable hash in the URL instead of +a cryptic generated one. +
+Tabs 2 already supported this functionality, although the history plugin needs a rewrite first (it doesn't support Safari 3 and is in general a little inflexible) before it can be build back into the tabs. It is planned and Klaus is working on it whenever he finds the time. Actual bugs in the UI Tabs plugin itself always have higher priority though. +
+var $tabs = $('#example').tabs(); +var selected = $tabs.tabs('option', 'selected'); // => 0+
"Hijax" links after tab content has been loaded: +
+$('#example').tabs({ + load: function(event, ui) { + $('a', ui.panel).click(function() { + $(ui.panel).load(this.href); + return false; + }); + } +});+
var $tabs = $('#example').tabs(); // first tab selected + +$('#my-text-link').click(function() { // bind click event to link + $tabs.tabs('select', 2); // switch to third tab + return false; +});+
Returning false in the tabs select handler prevents the clicked tab from becoming selected. +
+$('#example').tabs({ + select: function(event, ui) { + var isValid = ... // form validation returning true or false + return isValid; + } +});+
var $tabs = $('#example').tabs({ + add: function(event, ui) { + $tabs.tabs('select', '#' + ui.panel.id); + } +});+
Note that opening a tab in a new window is unexpected, e.g. +inconsistent behaviour exposing a usablity problem (http://www.useit.com/alertbox/tabs.html). +
+$('#example').tabs({ + select: function(event, ui) { + var url = $.data(ui.tab, 'load.tabs'); + if( url ) { + location.href = url; + return false; + } + return true; + } +});+
+
Add the necessary classes to hide an inactive tab panel to the HTML right away - note that this will not degrade gracefully with JavaScript being disabled: +
+<div id="example" class="ui-tabs"> + ... + <div id="a-tab-panel" class="ui-tabs-hide"> </div> + ... +</div>+
Any component that requires some dimensional computation for its initialization won't work in a hidden tab, because the tab panel itself is hidden via display: none
so that any elements inside won't report their actual width and height (0 in most browsers).
+
There's an easy workaround. Use the off-left technique for hiding inactive tab panels. E.g. in your style sheet replace the rule for the class selector ".ui-tabs .ui-tabs-hide" with +
+.ui-tabs .ui-tabs-hide { + position: absolute; + left: -10000px; +}+
For Google maps you can also resize the map once the tab is displayed like this: +
+$('#example').bind('tabsshow', function(event, ui) { + if (ui.panel.id == "map-tab") { + resizeMap(); + } +});+resizeMap() will call Google Maps' checkResize() on the particular map. +
.ui-tabs .ui-tabs-hide { + display: none; +}
$("#tabs").tabs(); ++
<!DOCTYPE html> +<html> +<head> + <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> + <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> + <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> + + <script> + $(document).ready(function() { + $("#tabs").tabs(); + }); + </script> +</head> +<body style="font-size:62.5%;"> + +<div id="tabs"> + <ul> + <li><a href="#fragment-1"><span>One</span></a></li> + <li><a href="#fragment-2"><span>Two</span></a></li> + <li><a href="#fragment-3"><span>Three</span></a></li> + </ul> + <div id="fragment-1"> + <p>First tab is active by default:</p> + <pre><code>$('#example').tabs();</code></pre> + </div> + <div id="fragment-2"> + Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. + Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. + </div> + <div id="fragment-3"> + Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. + Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. + Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. + </div> +</div> +</body> +</html> ++
This event is triggered when clicking a tab.
+select
event as an init option.
+$( ".selector" ).tabs({
+ select: function(event, ui) { ... }
+});
+select
event by type: tabsselect
.
+$( ".selector" ).bind( "tabsselect", function(event, ui) {
+ ...
+});
+This event is triggered after the content of a remote tab has been loaded.
+load
event as an init option.
+$( ".selector" ).tabs({
+ load: function(event, ui) { ... }
+});
+load
event by type: tabsload
.
+$( ".selector" ).bind( "tabsload", function(event, ui) {
+ ...
+});
+This event is triggered when a tab is shown.
+show
event as an init option.
+$( ".selector" ).tabs({
+ show: function(event, ui) { ... }
+});
+show
event by type: tabsshow
.
+$( ".selector" ).bind( "tabsshow", function(event, ui) {
+ ...
+});
+This event is triggered when a tab is added.
+add
event as an init option.
+$( ".selector" ).tabs({
+ add: function(event, ui) { ... }
+});
+add
event by type: tabsadd
.
+$( ".selector" ).bind( "tabsadd", function(event, ui) {
+ ...
+});
+This event is triggered when a tab is removed.
+remove
event as an init option.
+$( ".selector" ).tabs({
+ remove: function(event, ui) { ... }
+});
+remove
event by type: tabsremove
.
+$( ".selector" ).bind( "tabsremove", function(event, ui) {
+ ...
+});
+This event is triggered when a tab is enabled.
+enable
event as an init option.
+$( ".selector" ).tabs({
+ enable: function(event, ui) { ... }
+});
+enable
event by type: tabsenable
.
+$( ".selector" ).bind( "tabsenable", function(event, ui) {
+ ...
+});
+This event is triggered when a tab is disabled.
+disable
event as an init option.
+$( ".selector" ).tabs({
+ disable: function(event, ui) { ... }
+});
+disable
event by type: tabsdisable
.
+$( ".selector" ).bind( "tabsdisable", function(event, ui) {
+ ...
+});
+Remove the tabs functionality completely. This will return the element back to its pre-init state.
+Disable the tabs.
+Enable the tabs.
+Get or set any tabs option. If no value is specified, will act as a getter.
+Set multiple tabs options at once by providing an options object.
+Returns the .ui-tabs element.
+Add a new tab. The second argument is either a URL consisting of a fragment identifier only to create an in-page tab or a full url (relative or absolute, no cross-domain support) to turn the new tab into an Ajax (remote) tab. The third is the zero-based position where to insert the new tab. Optional, by default a new tab is appended at the end.
+Remove a tab. The second argument is the zero-based index of the tab to be removed.
+Enable a disabled tab. To enable more than one tab at once reset the disabled property like: $('#example').tabs("option","disabled",[]);
. The second argument is the zero-based index of the tab to be enabled.
Disable a tab. The selected tab cannot be disabled. To disable more than one tab at once use: $('#example').tabs("option","disabled", [1, 2, 3]);
The second argument is the zero-based index of the tab to be disabled.
Select a tab, as if it were clicked. The second argument is the zero-based index of the tab to be selected or the id selector of the panel the tab is associated with (the tab's href fragment identifier, e.g. hash, points to the panel's id).
+Reload the content of an Ajax tab programmatically. This method always loads the tab content from the remote location, even if cache is set to true. The second argument is the zero-based index of the tab to be reloaded.
+Change the url from which an Ajax (remote) tab will be loaded. The specified URL will be used for subsequent loads. Note that you can not only change the URL for an existing remote tab with this method, but also turn an in-page tab into a remote tab. The second argument is the zero-based index of the tab of which its URL is to be updated. The third is a URL the content of the tab is loaded from.
+Retrieve the number of tabs of the first matched tab pane.
+Terminate all running tab ajax requests and animations.
+Set up an automatic rotation through tabs of a tab pane. The second argument is an amount of time in milliseconds until the next tab in the cycle gets activated. Use 0 or null to stop the rotation. The third controls whether or not to continue the rotation after a tab has been selected by a user. Default: false.
+The jQuery UI Tabs plugin uses the jQuery UI CSS Framework to style its look and feel, including colors and background textures. We recommend using the ThemeRoller tool to create and download custom themes that are easy to build and maintain. +
+If a deeper level of customization is needed, there are widget-specific classes referenced within the jquery.ui.tabs.css stylesheet that can be modified. These classes are highlighed in bold below. +
+ +
+
+ Note: This is a sample of markup generated by the tabs plugin, not markup you should use to create a tabs. The only markup needed for that is
<div id="tabs">
+ <ul>
+ <li><a href="#tabs-1">Nunc tincidunt</a></li>
+ <li><a href="#tabs-2">Proin dolor</a></li>
+ <li><a href="#tabs-3">Aenean lacinia</a></li>
+ </ul>
+ <div id="tabs-1">
+ <p>Tab 1 content</p>
+ </div>
+ <div id="tabs-2">
+ <p>Tab 2 content</p>
+ </div>
+ <div id="tabs-3">
+ <p>Tab 3 content</p>
+ </div>
+</div>.
+
+
The enhanced toggle method optionally accepts jQuery UI advanced effects.
+Uses a specific effect on an element to toggle the element if the first argument is an effect string.
+$("p").click(function () { + $("div").toggle("slide", {}, 1000); + }); ++
<!DOCTYPE html> +<html> +<head> + <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> + <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> + <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> + <script src="http://ui.jquery.com/latest/ui/effects.core.js"></script> +<script src="http://ui.jquery.com/latest/ui/effects.slide.js"></script> +<style type="text/css"> + div { display: none; margin: 0px; width: 100px; height: 80px; background: blue; position: relative; } +</style> + <script> + $(document).ready(function() { + $("p").click(function () { + $("div").toggle("slide", {}, 1000); + }); + }); + </script> +</head> +<body style="font-size:62.5%;"> + +<p>Click me</p><div></div> + +</body> +</html> ++
Adds the specified class if it is not present, and removes the specified class if it is present, using an optional transition.
+$("p").click(function () { + $(this).toggleClass("selected", 1000); + }); ++
<!DOCTYPE html> +<html> +<head> + <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> + <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> + <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> + <script src="http://ui.jquery.com/latest/ui/effects.core.js"></script> +<style type="text/css"> + p { cursor: pointer; font-size: 1.2em; } + .selected { color:red; } +</style> + <script> + $(document).ready(function() { + $("p").click(function () { + $(this).toggleClass("selected", 1000); + }); + }); + </script> +</head> +<body style="font-size:62.5%;"> + +<p>Click me to toggle 'selected' class.</p> +<p class="selected">Click me to toggle 'selected' class.</p> +<p>Click me to toggle 'selected' class.</p> + +</body> +</html> ++