I wrote a javascript function that uses the innerHtml of a named div (that occurs immediately after the script) for each row as output. the problem is, if I use $('divname')
, it always finds the first instance, not the nearest. What's the simplest way in prototype to target the nearest "divname" div?
eg (note, I'm using Grails, hence the <g:...>
tags):
<g:each ... >
<tr>
<td colspan = "4">
<g:javascript>
...
$('outputdiv').innerHTML = theoutput;
</g:javascript>
<div id='outputdiv' /> //target THIS instance, not the first!
</td>
</tr>
</g:each>