Getting and Setting jQuery UI Plugin Options - J Query

Problem
You need to check or change the value of a jQuery UI plugin option after it has been initialized.

Solution 1: Getting the Value

Call the plugin’s option method, passing the name of the option:

When called with only an option name, the option method gets and returns the value, so it’s not chainable.

Solution 2: Setting the Value

Call the plugin’s option method, passing the name of the option and the new value:

When called with an option name and value, the option method sets the value and returns the jQuery object, so it’s chainable.

Discussion
The option method get/set follows the same pattern as jQuery getters and setters such as .css() and .attr(). If you provide a value, it’s a setter; if you omit the value, it’s a getter.
As with other jQuery setters, you can set multiple options at once by passing a hash to the option method:


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

J Query Topics