title: Select2 Get selected option data
body: <p><code>$("#e2").select2("val")</code> returns me the value, but I wan't to get the <code>.$listtypes['name'] .</code> ether from data-name or from the option tag display. </p>
  
  <p>I want to get the option data-name for the selected option, how can I accomplish this?</p>
  
  <p>This is my option generator</p>
  
  <pre><code>foreach($core-&gt;list_types() as $listtypes){
  echo "
  &lt;option 
    data-name='".$listtypes['name'] ."' 
    value='".$listtypes['id']."'&gt;
    ".$listtypes['name'] ."
  &lt;/option&gt;";
  }
  </code></pre>