What I want to do is insert a link and img for every thread of this forum I use. The href of the link should be based on the href of a child of the element. Here is a partial view of the HTML, I've taken out some things for clarity, let me know if I've taken too much. The very last tag repeats 20 or so times, depending how much threads are visible in preferences
<div id="content">
<form id="page_form">
<div id="forums">
<table class="grid forumtable">
<tr></tr>
<tr></tr>
<tr>
<td></td>
<td></td>
<td></td>
<td>
<div class="lastposter">
<a></a>
<a href="view/1234/?page=last#845612"><img></img></a>
</div>
</td>
</tr>
<tr> ...same as above.. x20 </tr>
</table>
</div>
</form>
</div>
So here is my code so far, which is working by inserting a static link. What I want, is the link to use the value after # from the previous link.
var lastpst = document.getElementsByClassName('lastposter');
for (var i=0; i < lastpst.length; i++){
links = document.createElement('a');
links.setAttribute('href','we.html');
links.innerHTML ='<a href="we.html"><img src="/static/img/silk/zoom.png" /></a>';
lastpst[i].appendChild(links);
}
So how can I access the a tag from lastpst[i] and use the href to create my own link?
I was thinking it could be possible to write this using XPATH but I couldn't quite get my head around it. Would it be a good idea in this case?
Sorry for the long-winded question.