[英]Get the value of span tag
I have a HTML <table>
, I succeed to iterate it using this code : 我有一个HTML <table>
,我成功使用以下代码对其进行了迭代:
var rows = document.querySelectorAll("#ff\\:tablereparation tr");
for (var i = 0; i < rows.length; i++) {
alert(rows[i].cells[0].innerHTML);
alert(rows[i].cells[1].innerHTML);
}
The problem is I had a result with a <span>
tag : 问题是我的结果带有<span>
标记:
<span id="ff:tablereparation:0:np">Panne grave</span>
I want just the value, in this case : Panne grave
, I tried with value
, text()
, val()
but it didn't work. 在这种情况下,我只想要值: Panne grave
,我尝试使用value
, text()
, val()
但是没有用。
Here's what you should do : 这是您应该做的:
var rows = document.querySelectorAll("#ff\\:tablereparation tr");
for (var i = 0; i < rows.length; i++) {
for (var j = 0; j < 2; j++) {
alert(rows[i].cells[j].textContent);
}
}
See this Fiddle for a demo. 看到这个小提琴演示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.