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