如何获取内部html值 [英] How to get the inner html value

查看:67
本文介绍了如何获取内部html值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<span style="color: red"> advertising cctv/bust</span><span style="color: red">a</span>tion
how to get the value from this text
I used replace function but it removing only once and it ignoring second one
how can i do this one

推荐答案


//for single element
getElementById('idofelement').innerHTML 
//for multiple element in your case
var span = getElementsByTagName('span');
for(var s=0;s<span.length;s++)
{
 alert('Inner HTML: ' + span[s].innerHTML);
}



如有任何疑问,请让我知道.

请提供"投票":thumbsup:如果有帮助,请提供"接受答案",如果这是正确的答案.:rose:

谢谢,
Imdadhusen



Please do let me know, if you have any doubt.

Please provide "Vote":thumbsup: if this would be helpful, and make "Accept Answer" if this would be correct answer.:rose:

Thanks,
Imdadhusen


不知道为什么要继续重新发布 [^ 一次又一次地问同样的问题,而不必在一处关注.

如果您的动机是将问题弹出到顶部,则可以编辑您的旧问题,然后将您的问题弹出到列表的顶部.
No idea why you keep on resposting [^]the same question again and again without following it at one place.

In case, you motive is to pop your question at the top, you can edit your old question and that will pop your question at the top of list.


这篇关于如何获取内部html值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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