是否必须在运行时将自定义标签插入HTML元素? [英] Have to insert custom tag into HTML element at runtime?

查看:70
本文介绍了是否必须在运行时将自定义标签插入HTML元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

场景:

表格和/或任何其他HTML元素已经存在于页面中,其中包含数据.我应该从每个元素读取数据,并在特定类型的数据周围包裹自定义标签.(应在onload事件上完成)

Scenario:

A table and or any other HTML elements are already present on the page with data in them. I should read the data from each element and wrap custom tags around the data which is of specific type.(This should be done on the onload event)

<table border="1"

id = "Table1">
<tr>
<td>CO@Property</td>
</tr>
<tr>
<td>Tag:Plugin@Property</td>
</tr>
</table>
<input id="UserTag1" type="text" value="Random1" style="text-align: right; width:50em">
<input id="UserTag2" type="text" value="Tag:Random1" style="text-align: right; width:50em">



任何以"Tag:"开头的输入字段中的任何数据都应包含在自定义标签"中



Any data in any input field starting with "Tag:" should be enclosed in a Custom Tag

<CSTag InputType = "Tag" TagValue = "value the user entered" />



因此,在OnLoad之后,代码应如下所示:



So After OnLoad the code should look like this:

<table border="1"

id = "Table1">
<tr>
<td>CO@Property</td>
</tr>
<tr>
<td><CSTag InputType = "Tag" TagValue = "Plugin@Property" /></td>
</tr>
</table>
<input id="UserTag1" type="text" value="Random1" style="text-align: right; width:50em">
<input id="UserTag2" type="text" value="<CSTag InputType = "Tag" TagValue = "Random1" />"style="text-align: right; width:50em">



我该如何实现?我想提取特定类型的用户数据并将其包装在标签周围.



How do i achieve this? I want to pull out user data of specific type and wrap them around tags.

推荐答案

请参阅我的评论,最好不要尝试使用自定义标签" ".除此之外,没有问题.您可以使用document.getElementById来获取某些元素并分配其属性innerHTML.请参阅:
http://www.w3schools.com/jsref/met_doc_getelementbyid.asp [ http://www.w3schools.com/jsref/prop_html_innerhtml.asp [
Please see my comment and better don''t try to use a "custom tag". Other than that, there is no problem. You can use document.getElementById to get some element and assign its property innerHTML. Please see:
http://www.w3schools.com/jsref/met_doc_getelementbyid.asp[^],
http://www.w3schools.com/jsref/prop_html_innerhtml.asp[^].

Please see the code sample shown in the second page referenced above.

—SA


这篇关于是否必须在运行时将自定义标签插入HTML元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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