在< option>中添加span标签和样式它 [英] Add span inside <option> tag and style it

查看:1669
本文介绍了在< option>中添加span标签和样式它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在< option> 标记和样式之前的文本中添加span(它应该在选择菜单中代表颜色)。

I would like to add span before text inside <option> tag and style it (it should represent color in select menu). However it does't seem to work...

如何使这段代码正常工作?

How to make this piece of code working?

JsFiddle: http://jsfiddle.net/bartuz/08e0L9j2/2/

JsFiddle: http://jsfiddle.net/bartuz/08e0L9j2/2/

推荐答案

这将取决于您的网络浏览器。在最新版本的Firefox中,它工作正常。但是,它不能在最新版本的Internet Explorer中使用。

This will depend on your web browser. In the latest version of Firefox, it works fine. However, it doesn't work in the latest version of Internet Explorer.

您的问题有点加载 - 我怀疑这就是为什么它downvoted - 你问为什么

Your question is a bit loaded - and I suspect that's why it got downvoted - you are asking why it's not working, rather than how to get it to work.

它不工作,因为它不是真正的selectboxes支持的功能(尚未!)

It's not working because it's not really a supported feature of selectboxes (yet!)

我建议您使用JavaScript来实现相同的结果(具体来说, jQuery UI selectmenu ),它应该支持这种类型的'高级'选择框。

I'd suggest you look into using JavaScript to achieve the same result (and specifically, the jQuery UI selectmenu) which should support this type of 'advanced' select box.

这篇关于在&lt; option&gt;中添加span标签和样式它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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