I'm almost there with something thanks to the help of stackoverflow users. I just need a bit more help with this one.
I have a HTML page with a dynamically generated table of data which I cannot alter view. It's returned like this:
<tr>
<td class="name">foo<</td>
<td class="time">5:36:13</td>
<td class="avtime">0:09:36</td>
<td class="transcripts">0</td><td class="views">35</td>
<td class="percent">100</td>
</tr>
What I need to do is find and replace:
<td class="percent">$foo</td>
With:
<td class="percent"><span class="bar" style="width:$foo%"></span></td>
As I say I was almost there and have replacements working just not with variable values.
What I have now:
function replaceScript() {
var toReplace = '<td class="percent">69</td>';
var replaceWith ='<td class="percent"><span class="bar" style="width:69%"></span> </td>';
document.body.innerHTML = document.body.innerHTML.replace(toReplace, replaceWith);
}
Can you help?
Thanks in advance
document.body.innerHTMLin their code it's the actual page DOM.