diff --git a/index.html b/index.html index cfdbe97d..33c682d7 100644 --- a/index.html +++ b/index.html @@ -1469,15 +1469,14 @@ $("#select").select2({
val
method invoked on a single-select with an unset value will return ""
, while a val
method invoked on an empty multi-select will return []
alert("Selected value is: "+$("#e8").select2("val")); $("#e8").select2("val", {id:"CA", text:"Califoria"});+ Example:
alert("Selected value is: "+$("#e8").select2("val")); $("#e8").select2("val", "CA"});+
Notice that in order to use this method you must define the initSelection
function in the options so Select2 knows how to transform the id of the object you pass in val()
to the full object it needs to render selection. If you are attaching to a select
element this function is already provided for you.
Gets or sets the selection. Analogous to val
method, but works with objects instead of ids.
data
method invoked on a single-select with an unset value will return null
, while a data
method invoked on an empty multi-select will return []
val
method invoked on a single-select with an unset value will return ""
, while a val
method invoked on an empty multi-select will return []
alert("Selected value is: "+$("#e8").select2("val")); $("#e8").select2("val", {id:"CA", text:"Califoria"});+ Example:
alert("Selected value is: "+$("#e8").select2("val")); $("#e8").select2("val", "CA"});+
Notice that in order to use this method you must define the initSelection
function in the options so Select2 knows how to transform the id of the object you pass in val()
to the full object it needs to render selection. If you are attaching to a select
element this function is already provided for you.