There are few ways to programmatically access the selection data. Calling <code>select2('data')</code> will return the JavaScript array of an objects representing the current selection. Each object will have properties/values which was in the source data objects passed through <code>processResults</code> and <code>templateResult</code> functions (as in <ahref="#data">Loading data from an array</a> and <ahref="#ajax">Connecting to a remote data source</a>).
As Select2 uses the HTML <code><SELECT></code> element to store the selection result, the selection data are represented by <code><OPTION></code> elements and can be accessed in the plain jQuery/DOM manner:
It is possible to extend the <code><OPTION></code> elements representing selection with the HTML data-* attributes containing arbitrary data from the source data objects: