seamusleahy / getOptions

jQuery plugin to get the `option`s values

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

jQuery.getOptions()

Nothing fancy, just helpful. A jQuery plugin to get back a Javascript data structure of the options for use within advance widgets.

Example

<select id="s">
  <option value="a" data-custom="food">A option</option>
  <option value="b">B option</option>
</select>
$('#s').getOptions()
=> {
  'a': {
    label: 'A option', 
    value: 'a', 
    selected: false, 
    disabled: false, 
    data: {
      custom: 'food'
    }, 
    toString: function(){...}
  },
    
  'b': {
    label: 'B option', 
    value: 'a', 
    selected: false, 
    disabled: false, 
    data: {}, 
    toString: function(){}
  }
}

Options

flip boolean (false): flip the key from value to label and toString from label to value html boolean (false): the label will have the full HTML instead of just the text

About

jQuery plugin to get the `option`s values


Languages

Language:JavaScript 100.0%