bootstrap选择选项显示值而不是文本

这可能已经得到了解答,但我认为这个问题没有得到解答。

我有一个Dropbox(选择和选项),我想在未选择保管箱时在屏幕上显示该值,并在选择该文本时显示该文本

例:

 description0 description1 description2  

所以当我想选择一个选项时,我想显示描述。 但我想在保管箱字段中显示所选选项的值(当我没有选择某些内容时)

这可能吗?

提前致谢

像这样的东西?

Bootply : http : //www.bootply.com/128894

JS

 $('#inputmsgType').on('change mouseleave', function(){ $('#inputmsgType option').each(function(){ $(this).html( $(this).attr('desc') ); }); $('#inputmsgType option:selected').html( $('#inputmsgType option:selected').attr('value') ); }); $('#inputmsgType').on('mouseover', function(){ $('#inputmsgType option').each(function(){ $(this).html( $(this).attr('desc') ); }); }); 

HTML

  

使用Jquery代码,试试这个:

 $('#inputmsgType').click(function() { $('#description').html("Option value is:" + $('#inputmsgType').val() + "
Option Description is: " + $('#inputmsgType option:selected').text()); });