包含HTML和JavaScript标记的HTML选择控件作为文本
16lz
2021-01-22
I have a select control getting values dynamically. In the script, I need to insert the following text inside the select tags as its inner html.
我有一个选择控件动态获取值。在脚本中,我需要在select标签内插入以下文本作为其内部html。
<option value=""></option>
<option><h1>zoot</h1></option>
<option><div>divTest</div></option>
<option><span> style="color:red;font-weight:bold;">SpanTest</span></option>
<option><option>option</optipon></option>
What I am trying to do is in the picture below
我想要做的是在下面的图片中
I tried using HTMLEncode and that was not working too. Am I able to do this using JavaScript or jQuery or by any other means in html select control ?
我尝试使用HTMLEncode,但也没有用。我可以使用JavaScript或jQuery或通过html选择控件中的任何其他方式执行此操作吗?
2 个解决方案
#1
0
It you want the HTML to be user-visible, you need to encode it. Working example below.
您希望HTML是用户可见的,您需要对其进行编码。下面的工作示例。
<select name="example">
<option value=""></option>
<option><h1>zoot</h1></option>
<option><div>divTest</div></option>
<option><span> style="color:red;font-weight:bold;">SpanTest</span></option>
<option><option>option</optipon></option>
</select>
更多相关文章
- 嵌套水平滑块与单击控件
- arcgis api for js入门开发系列十 自定义Navigation控件样式风格
- struts2结合swfupload控件实现视频等大文件上传
- 获取错误“ValueError:int()的无效文字,基数为10:'3128;'在运行Tensor
- python的接口实现zope.interface示例
- Python套接字代理示例,不断收到调用bind()的错误..为什么?
- sqlserver 差异备份与还原示例
- sqlmap遇到url重写的示例
- Android中RecyclerView的item中控件的点击事件添加删除一行、上