如何在JAVAscript中获取HTML标签的值 [英] How to get value of HTML tag in JAVAscript
本文介绍了如何在JAVAscript中获取HTML标签的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我的HTML标签为
Hi
my HTML tag as
<table><thead><th id="UltraWebGridData_c_0_4" class="abc" hieght="" style="">
<nobr>First Name
</nobr>
<th>
</th></th></thead></table>
我必须在javascript中获取名字作为文本.
我也不能更改上面的代码,因为它是由C#代码自动/动态生成的.
请给我建议.
谢谢
I have to get first name as a text in javascript.
also I cant change the above code because it is automatically/dynamically generated by C# code
please suggest me.
Thanks
推荐答案
如果它是由C#代码动态生成的,则无法通过这种方式获取.
像这样使用...
If it is dynamically generated by the C# code then you cant get by this way..
Use like this...
document.getElementByID("<%= Element.ClientID %>").innerText or innerHTML
因为asp.net的每个控件都有
because every control of a asp.net has
runat="server"
,这意味着该控件的HTML代码由ASp.Net生成,其ID也由C#生成.
which means that the HTML code for the control is generated by ASp.Net and its id is also generated by C#.
您可以在javascript中获取包含id属性的任何html标记
Hi,
You can get any html tag in javascript which are contains Id property
document.getElementByID("Id of that html Tag").innerText or .innerHTML
尝试此操作,您可以获取内部html标签或该标签内的内部文本k
一切顺利
Try this you can get inner html tags or inner text within that tag k
All the best
http://www. javascript-coder.com/javascript-form/javascript-get-form.phtml [
这篇关于如何在JAVAscript中获取HTML标签的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文