我可以在选择元素的选项中使用HTML标记吗? [英] Can I use HTML tags in the options for select elements?

查看:101
本文介绍了我可以在选择元素的选项中使用HTML标记吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HTML选择元素的选项是否可以包含HTML标签?

Is it possible for the options of an HTML select element to include HTML tags?

例如,给定以下代码:

 <select>
    <option value="one"><b>one is bold</b></option>
    <option value="two">two has some <span style='color:red;'>red</span> text</option>
    <option value="three">three is just normal</option>
 </select>

我想要的选项实际上在HTML中呈现。在这个应用程序中,我可以使用HTML,CSS,JavaScript(包括jQuery)。而且HTML本身是通过Django(django.form.fields.select)渲染的。

I would like the options to actually render in HTML. In this application I can play with HTML, CSS, JavaScript (including jQuery). And the HTML itself is being rendered via Django (django.form.fields.select).

推荐答案

不,你不能做这个。 < option> 标签不能包含任何其他标签。

No, you can't do this. <option> tags cannot contain any other tags.

这篇关于我可以在选择元素的选项中使用HTML标记吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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