HTML选择显示值而不是文本 [英] HTML select shows value instead of text

查看:174
本文介绍了HTML选择显示值而不是文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在 html选择中显示选项的值而不是文本?

它将用于在下拉菜单中显示长时间的提示,但是选择时应该只显示简短的文本/选项的值。



code:

 < select> 
< option value =1>这是一个很长的文本,它解释了选项1< / option>
< option value =2>这是一个很长的文本,解释了选项2< / option>
< / select>

现在选定的项目,当您离开下拉/组合框时,应该只显示'1'

解决方案

您可以通过使用标签标签来完成: $ p> < option value =the_valuelabel =显示的文字>隐藏文字< / option>


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 dropdown, but when selecting it should only be showing a short text/ the value of the option.

code:

<select>
    <option value="1">This is a long long text, that explains option 1</option>
    <option value="2">This is a long long text, that explains option 2</option>
</select>

Now the selected item, when you leave the dropdown/combobox/whatever, should only display '1'

解决方案

You can do it by using the label tag:

<option value="the_value" label="the text displayed">the hidden text</option>

这篇关于HTML选择显示值而不是文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆