Is it possible in a html select
, to display the value of the option instead of the text?
It\'s gonna be used for displaying a long disription in the dro
I found a solution that might solve your problem:
HTML:
jQuery:
$('#countryCode option:selected').html($('#countryCode option:selected').attr('value')); // already changed onload
$('#countryCode').on('change mouseleave', function(){
$('#countryCode option').each(function(){
$(this).html( $(this).attr('data-text') );
});
$('#countryCode option:selected').html( $('#countryCode option:selected').attr('value') );
$(this).blur();
});
$('#countryCode').on('focus', function(){
$('#countryCode option').each(function(){
$(this).html( $(this).attr('data-text') );
});
});
http://jsfiddle.net/9y43gh4x/