Reputation: 1099
I'm trying to alert only values without html tags from a selected table row. What's wrong with the following function:
function show_table_row(row) {
var arr = [];
var t_row = document.getElementById("table_id").rows[row].innerHTML;
for (var i = 0; i < t_red.length; i++)
{
arr.push(t_row [i]);
}
alert(arr.join("\n"));
}
Upvotes: 0
Views: 2750
Reputation: 4360
Change your innerHTML to innerText
var t_row = document.getElementById("table_id").rows[row].innerText;
Edit:- Thanks to Alex W for poitning out , you can use .textContent , since firefox does not support innerText. It is otherwise supported on all major browsers. But note that .textContent is not supported on older versions of IE (before IE9) http://www.quirksmode.org/dom/w3c_html.html
Upvotes: 2
Reputation: 38193
Use .textContent
because .innerText
is not a standardized W3 property.
'innerText' works in IE, but not in Firefox
Upvotes: 3