隐藏选择控件中的文本 [英] hide the text inside select control

查看:42
本文介绍了隐藏选择控件中的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何隐藏选项内写的部分文本?

How can I hide the part of the text written inside of the option?

我尝试了以下操作:

<select name='what'>
   <option value='some value'>Value to be shown <span class='hide'>value to be hidden</span></option>
   ....
</select>

这是CSS。

.hide{ visibility : hidden; }

但这似乎不起作用。我还尝试过 display:none 而不是 visibility:hidden ,但这也不起作用。

But it doesn't seem to work. I've also tried display:none instead of visibility:hidden but that doesn't work either.

PS:为什么我要这样做?我想要这样做是因为我希望将隐藏文本包含在搜索中。

P.S: Why I want to do this? I want to do this because I want the hidden text to be included in the search.

更新我很清楚可以使用html5元标记来实现,但是很遗憾,我不能在这里使用使用名为 Chosen 的Jquery插件,它不支持对元标记的搜索。

UPDATE I am well aware that it may be achieved using the html5 meta tags, but unfortunately that I can't use here as I am using Jquery plugin called Chosen and it doesn't support the search over meta tags.

推荐答案

您不能这样做。 < option> 标签不能包含任何其他标签。使用 Select2

You can't do this. <option> tag cannot contain any other tags. Use Select2

这篇关于隐藏选择控件中的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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